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/history.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/profiler.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/profile_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/web/rack_app.rb,
lib/wurk/configuration.rb,
lib/wurk/limiter/leaky.rb,
lib/wurk/metrics/query.rb,
lib/wurk/scheduled_set.rb,
lib/wurk/web/extension.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/redis_connection.rb,
lib/wurk/swarm/child_boot.rb,
lib/wurk/web/batch_status.rb,
lib/wurk/limiter/unlimited.rb,
lib/wurk/middleware/expiry.rb,
lib/wurk/batch/callback_job.rb,
lib/wurk/dashboard_manifest.rb,
lib/wurk/iterable_job_query.rb,
lib/wurk/limiter/concurrent.rb,
lib/wurk/batch/death_handler.rb,
lib/wurk/metrics/queue_rollup.rb,
lib/wurk/redis_client_adapter.rb,
lib/wurk/middleware/poison_pill.rb,
lib/wurk/batch/client_middleware.rb,
lib/wurk/batch/server_middleware.rb,
lib/wurk/transaction_aware_client.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/iterable_job/csv_enumerator.rb,
lib/wurk/middleware/interrupt_handler.rb,
lib/wurk/middleware/current_attributes.rb,
app/controllers/wurk/profiles_controller.rb,
app/controllers/wurk/dashboard_controller.rb,
app/controllers/wurk/extensions_controller.rb,
app/controllers/wurk/application_controller.rb,
lib/generators/wurk/install/install_generator.rb,
lib/wurk/iterable_job/active_record_enumerator.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, Profiler, Queues, RedisConnection, Scheduled, Testing, Unique, Worker Classes: ApiController, ApplicationController, Batch, BatchSet, CLI, Capsule, Client, Configuration, DashboardController, DeadSet, Deploy, Embedded, Engine, Error, ExtensionsController, Fetcher, Heartbeat, History, IterableJobQuery, JobLogger, JobRecord, JobRetry, JobSet, Launcher, Leader, Logger, Manager, Process, ProcessSet, Processor, ProfileRecord, ProfileSet, ProfilesController, Queue, Railtie, RedisClientAdapter, RedisPool, RetrySet, ScheduledSet, Shutdown, SortedEntry, SortedSet, Stats, Swarm, Topology, TransactionAwareClient, 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 =
"1.0.1"- 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
-
.enter_server_mode(config = configuration) ⇒ Object
Enter server mode: set the module flag (read by third-party gems via ‘Sidekiq.server?`) AND the per-config `server?` predicate that gates `configure_server`.
-
.load_json(string) ⇒ Object
— JSON ———————————————————.
- .logger ⇒ Object
- .logger=(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).
-
.transactional_push! ⇒ Object
Opt in to enqueue-after-commit globally: every ‘perform_async` builds a Wurk::TransactionAwareClient that defers its push to the surrounding ActiveRecord transaction’s commit.
Class Attribute Details
.server=(value) ⇒ Object (writeonly)
Sets the attribute server
192 193 194 |
# File 'lib/wurk.rb', line 192 def server=(value) @server = value end |
Class Method Details
.configuration ⇒ Object Also known as: default_configuration
111 112 113 |
# File 'lib/wurk.rb', line 111 def configuration @configuration ||= Configuration.new end |
.configure_client ⇒ Object
91 92 93 |
# File 'lib/wurk.rb', line 91 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`.
101 102 103 104 105 106 107 108 109 |
# File 'lib/wurk.rb', line 101 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
87 88 89 |
# File 'lib/wurk.rb', line 87 def configure_server(&) configuration.configure_server(&) end |
.default_job_options ⇒ Object
— default job options —————————————–
147 148 149 |
# File 'lib/wurk.rb', line 147 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.
153 154 155 |
# File 'lib/wurk.rb', line 153 def (hash) @default_job_options = .merge(hash.transform_keys(&:to_s)) end |
.dump_json(object) ⇒ Object
141 142 143 |
# File 'lib/wurk.rb', line 141 def dump_json(object) ::JSON.generate(object) end |
.ent? ⇒ Boolean
211 212 213 |
# File 'lib/wurk.rb', line 211 def ent? false end |
.enter_server_mode(config = configuration) ⇒ Object
Enter server mode: set the module flag (read by third-party gems via ‘Sidekiq.server?`) AND the per-config `server?` predicate that gates `configure_server`. Both must be set before the app’s initializers run, or ‘configure_server` blocks (server middleware, error handlers, lifecycle hooks) are silently skipped. Defaults to the global config; the CLI passes its own (possibly test-injected) Configuration instance.
200 201 202 203 |
# File 'lib/wurk.rb', line 200 def enter_server_mode(config = configuration) @server = true config[:server] = true end |
.load_json(string) ⇒ Object
— JSON ———————————————————
137 138 139 |
# File 'lib/wurk.rb', line 137 def load_json(string) ::JSON.parse(string) end |
.logger ⇒ Object
127 128 129 |
# File 'lib/wurk.rb', line 127 def logger configuration.logger end |
.logger=(logger) ⇒ Object
131 132 133 |
# File 'lib/wurk.rb', line 131 def logger=(logger) configuration.logger = 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?.
207 208 209 |
# File 'lib/wurk.rb', line 207 def pro? false end |
.redis ⇒ Object
116 117 118 |
# File 'lib/wurk.rb', line 116 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.
123 124 125 |
# File 'lib/wurk.rb', line 123 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).
188 189 190 |
# File 'lib/wurk.rb', line 188 def server? !!@server end |
.strict_args!(mode = :raise) ⇒ Object
Sets the global mode used by Wurk::JobUtil#verify_json. mode ∈ [:raise, :warn, false].
168 169 170 |
# File 'lib/wurk.rb', line 168 def strict_args!(mode = :raise) @strict_args_mode = mode end |
.strict_args_mode ⇒ Object
‘defined?` distinguishes “never set” from “set to false”.
173 174 175 |
# File 'lib/wurk.rb', line 173 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.
182 |
# File 'lib/wurk.rb', line 182 def testing!(mode = :fake, &) = Wurk::Testing.__set_test_mode(mode, &) |
.testing? ⇒ Boolean
True when in :fake or :inline mode (i.e. not pushing to real Redis).
185 |
# File 'lib/wurk.rb', line 185 def testing? = Wurk::Testing.enabled? |
.transactional_push! ⇒ Object
Opt in to enqueue-after-commit globally: every ‘perform_async` builds a Wurk::TransactionAwareClient that defers its push to the surrounding ActiveRecord transaction’s commit. Idempotent. Spec: sidekiq-free.md §3.
160 161 162 |
# File 'lib/wurk.rb', line 160 def transactional_push! ['client_class'] = Wurk::TransactionAwareClient end |