module Sidekiq::Worker
Overview
Include this module in your worker class and you can easily create asynchronous jobs:
class HardWorker include Sidekiq::Worker
def perform(a : Int64, b : Int32, c : Float64) # do some work end end
Note that you must annotate your perform method arguments so so that Sidekiq knows how to marshal your jobs at compile-time.
To create a new job, you do this:
HardWorker.async.perform(1_i64, 2, 3_f64)
You can set default job options per-Worker with sidekiq_options
:
class HardWorker include Sidekiq::Worker sidekiq_options do |job| job.queue = "critical" job.retry = 5 end
You can dynamically customize job options by passing a block to +async+, like so:
HardWorker.async do |job| # job is a Sidekiq::Job job.queue = "foo" job.retry = false end.perform(1_i64, 2, 3_f64)
Defined in:
sidekiq/worker.crConstant Summary
-
OPTION_BLOCKS =
Hash(String, Proc(Sidekiq::Job, Nil)).new
Instance Method Summary
- #bid : String | Nil
- #bid=(bid : String | Nil)
- #jid : String
- #jid=(jid : String)
- #jid? : String | Nil
- #logger
- #logger=(logger : Log)
- #logger? : Log | Nil