Module: Wurk
- Defined in:
- lib/wurk/active_job/wrapper.rb,
lib/wurk.rb,
lib/wurk/cli.rb,
lib/wurk/job.rb,
lib/wurk/lua.rb,
lib/wurk/web.rb,
lib/wurk/cron.rb,
lib/wurk/keys.rb,
lib/wurk/batch.rb,
lib/wurk/queue.rb,
lib/wurk/stats.rb,
lib/wurk/swarm.rb,
lib/wurk/client.rb,
lib/wurk/deploy.rb,
lib/wurk/engine.rb,
lib/wurk/health.rb,
lib/wurk/leader.rb,
lib/wurk/logger.rb,
lib/wurk/queues.rb,
lib/wurk/unique.rb,
lib/wurk/worker.rb,
lib/wurk/capsule.rb,
lib/wurk/context.rb,
lib/wurk/fetcher.rb,
lib/wurk/job_set.rb,
lib/wurk/limiter.rb,
lib/wurk/manager.rb,
lib/wurk/metrics.rb,
lib/wurk/railtie.rb,
lib/wurk/testing.rb,
lib/wurk/version.rb,
lib/wurk/api/fast.rb,
lib/wurk/dead_set.rb,
lib/wurk/embedded.rb,
lib/wurk/job_util.rb,
lib/wurk/launcher.rb,
lib/wurk/topology.rb,
lib/wurk/work_set.rb,
lib/wurk/batch_set.rb,
lib/wurk/component.rb,
lib/wurk/heartbeat.rb,
lib/wurk/job_retry.rb,
lib/wurk/processor.rb,
lib/wurk/retry_set.rb,
lib/wurk/scheduled.rb,
lib/wurk/encryption.rb,
lib/wurk/job_logger.rb,
lib/wurk/job_record.rb,
lib/wurk/lua/loader.rb,
lib/wurk/middleware.rb,
lib/wurk/redis_pool.rb,
lib/wurk/web/config.rb,
lib/wurk/web/search.rb,
lib/wurk/batch/empty.rb,
lib/wurk/job/options.rb,
lib/wurk/process_set.rb,
lib/wurk/batch/buffer.rb,
lib/wurk/batch/status.rb,
lib/wurk/iterable_job.rb,
lib/wurk/limiter/base.rb,
lib/wurk/sorted_entry.rb,
lib/wurk/configuration.rb,
lib/wurk/limiter/leaky.rb,
lib/wurk/metrics/query.rb,
lib/wurk/scheduled_set.rb,
lib/wurk/worker/setter.rb,
lib/wurk/fetcher/reaper.rb,
lib/wurk/limiter/bucket.rb,
lib/wurk/limiter/points.rb,
lib/wurk/limiter/window.rb,
lib/wurk/metrics/rollup.rb,
lib/wurk/metrics/statsd.rb,
lib/wurk/web/enterprise.rb,
lib/wurk/batch/callbacks.rb,
lib/wurk/client/buffered.rb,
lib/wurk/metrics/history.rb,
lib/wurk/middleware/i18n.rb,
lib/wurk/fetcher/reliable.rb,
lib/wurk/middleware/chain.rb,
lib/wurk/swarm/child_boot.rb,
lib/wurk/limiter/unlimited.rb,
lib/wurk/middleware/expiry.rb,
lib/wurk/batch/callback_job.rb,
lib/wurk/dashboard_manifest.rb,
lib/wurk/limiter/concurrent.rb,
lib/wurk/batch/death_handler.rb,
lib/wurk/middleware/poison_pill.rb,
lib/wurk/batch/client_middleware.rb,
lib/wurk/batch/server_middleware.rb,
lib/wurk/limiter/server_middleware.rb,
app/controllers/wurk/api/pagination.rb,
app/controllers/wurk/api_controller.rb,
app/controllers/wurk/api/serializers.rb,
lib/wurk/middleware/interrupt_handler.rb,
lib/wurk/middleware/current_attributes.rb,
app/controllers/wurk/dashboard_controller.rb,
app/controllers/wurk/application_controller.rb,
lib/generators/wurk/install/install_generator.rb
Overview
Wurk-namespaced alias kept tight against the Sidekiq definition above; the extra module is a pure constant rebind, not a second class definition.
Defined Under Namespace
Modules: API, ActiveJob, Api, Component, Context, Cron, DashboardManifest, Encryption, Generators, Health, IterableJob, Job, JobUtil, Keys, Limiter, Lua, Metrics, Middleware, Queues, Scheduled, Testing, Unique, Worker Classes: ApiController, ApplicationController, Batch, BatchSet, CLI, Capsule, Client, Configuration, DashboardController, DeadSet, Deploy, Embedded, Engine, Error, Fetcher, Heartbeat, JobLogger, JobRecord, JobRetry, JobSet, Launcher, Leader, Logger, Manager, Process, ProcessSet, Processor, Queue, Railtie, RedisPool, RetrySet, ScheduledSet, Shutdown, SortedEntry, SortedSet, Stats, Swarm, Topology, Web, Work, WorkSet
Constant Summary collapse
- DEFAULT_JOB_OPTIONS =
Process-wide job option defaults. Per-class options from ‘sidekiq_options` take precedence; this hash is the floor.
{ 'retry' => true, 'queue' => 'default' }.freeze
- Periodic =
Cron- VERSION =
"0.0.5"- Workers =
Deprecated alias. Sidekiq <8 used ‘Workers` for what is now `WorkSet`; third-party gems may still reference it. Resolved at load time so the alias survives a constant lookup by either name.
WorkSet
Class Attribute Summary collapse
-
.server ⇒ Object
writeonly
Sets the attribute server.
Class Method Summary collapse
- .configuration ⇒ Object (also: default_configuration)
- .configure_client ⇒ Object
-
.configure_embed {|configuration| ... } ⇒ Object
Embedded mode: caller runs Wurk inside its own process (Puma, rake task, etc.) without forking.
- .configure_server ⇒ Object
-
.default_job_options ⇒ Object
— default job options —————————————–.
-
.default_job_options=(hash) ⇒ Object
Merges (does not replace) into the current defaults.
- .dump_json(object) ⇒ Object
- .ent? ⇒ Boolean
-
.load_json(string) ⇒ Object
— JSON ———————————————————.
- .logger ⇒ Object
-
.pro? ⇒ Boolean
Wurk ships Pro+Ent features in the free gem; these flags exist solely for third-party gems that branch on Sidekiq.pro? / Sidekiq.ent?.
- .redis ⇒ Object
-
.redis_pool ⇒ Object
Capsule-aware pool lookup.
-
.server? ⇒ Boolean
True inside the swarm/manager process (set by exe/wurk / the railtie).
-
.strict_args!(mode = :raise) ⇒ Object
Sets the global mode used by Wurk::JobUtil#verify_json.
-
.strict_args_mode ⇒ Object
‘defined?` distinguishes “never set” from “set to false”.
-
.testing!(mode = :fake) ⇒ Object
Sidekiq-compatible test-mode entry point.
-
.testing? ⇒ Boolean
True when in :fake or :inline mode (i.e. not pushing to real Redis).
Class Attribute Details
.server=(value) ⇒ Object (writeonly)
Sets the attribute server
175 176 177 |
# File 'lib/wurk.rb', line 175 def server=(value) @server = value end |
Class Method Details
.configuration ⇒ Object Also known as: default_configuration
105 106 107 |
# File 'lib/wurk.rb', line 105 def configuration @configuration ||= Configuration.new end |
.configure_client ⇒ Object
85 86 87 |
# File 'lib/wurk.rb', line 85 def configure_client(&) configuration.configure_client(&) end |
.configure_embed {|configuration| ... } ⇒ Object
Embedded mode: caller runs Wurk inside its own process (Puma, rake task, etc.) without forking. Concurrency is defaulted to 2 — the GIL makes higher thread counts counterproductive inside a host process that has its own pool. The block can override anything before the Embedded instance is built. Returns a Wurk::Embedded the caller drives with ‘#run` / `#quiet` / `#stop`.
95 96 97 98 99 100 101 102 103 |
# File 'lib/wurk.rb', line 95 def if configuration.frozen? raise FrozenError, 'Wurk configuration is frozen; build all embedded instances before calling run' end configuration.concurrency = 2 yield configuration if block_given? Embedded.new(configuration) end |
.configure_server ⇒ Object
81 82 83 |
# File 'lib/wurk.rb', line 81 def configure_server(&) configuration.configure_server(&) end |
.default_job_options ⇒ Object
— default job options —————————————–
137 138 139 |
# File 'lib/wurk.rb', line 137 def @default_job_options ||= DEFAULT_JOB_OPTIONS.dup end |
.default_job_options=(hash) ⇒ Object
Merges (does not replace) into the current defaults. Keys are stringified so symbol-keyed callers don’t shadow string keys.
143 144 145 |
# File 'lib/wurk.rb', line 143 def (hash) @default_job_options = .merge(hash.transform_keys(&:to_s)) end |
.dump_json(object) ⇒ Object
131 132 133 |
# File 'lib/wurk.rb', line 131 def dump_json(object) ::JSON.generate(object) end |
.ent? ⇒ Boolean
183 184 185 |
# File 'lib/wurk.rb', line 183 def ent? false end |
.load_json(string) ⇒ Object
— JSON ———————————————————
127 128 129 |
# File 'lib/wurk.rb', line 127 def load_json(string) ::JSON.parse(string) end |
.logger ⇒ Object
121 122 123 |
# File 'lib/wurk.rb', line 121 def logger configuration.logger end |
.pro? ⇒ Boolean
Wurk ships Pro+Ent features in the free gem; these flags exist solely for third-party gems that branch on Sidekiq.pro? / Sidekiq.ent?.
179 180 181 |
# File 'lib/wurk.rb', line 179 def pro? false end |
.redis ⇒ Object
110 111 112 |
# File 'lib/wurk.rb', line 110 def redis(&) redis_pool.with(&) end |
.redis_pool ⇒ Object
Capsule-aware pool lookup. Thread-local override wins so per-capsule workers (‘Thread.current = cap`) read from their own connections without leaking to the default capsule.
117 118 119 |
# File 'lib/wurk.rb', line 117 def redis_pool (Thread.current[:wurk_capsule] || configuration.default_capsule).redis_pool end |
.server? ⇒ Boolean
True inside the swarm/manager process (set by exe/wurk / the railtie).
171 172 173 |
# File 'lib/wurk.rb', line 171 def server? !!@server end |
.strict_args!(mode = :raise) ⇒ Object
Sets the global mode used by Wurk::JobUtil#verify_json. mode ∈ [:raise, :warn, false].
151 152 153 |
# File 'lib/wurk.rb', line 151 def strict_args!(mode = :raise) @strict_args_mode = mode end |
.strict_args_mode ⇒ Object
‘defined?` distinguishes “never set” from “set to false”.
156 157 158 |
# File 'lib/wurk.rb', line 156 def strict_args_mode defined?(@strict_args_mode) ? @strict_args_mode : Configuration::DEFAULTS[:on_complex_arguments] end |
.testing!(mode = :fake) ⇒ Object
Sidekiq-compatible test-mode entry point. Delegates to Wurk::Testing (the single source of truth for the mode): a block scopes the mode to the current thread; no block sets it globally. ‘Sidekiq.testing!` aliases here.
165 |
# File 'lib/wurk.rb', line 165 def testing!(mode = :fake, &) = Wurk::Testing.__set_test_mode(mode, &) |