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.cr

Constant Summary

OPTION_BLOCKS = Hash(String, Proc(Sidekiq::Job, Nil)).new

Instance Method Summary

Instance Method Detail

def bid : String | Nil #

[View source]
def bid=(bid : String | Nil) #

[View source]
def jid : String #

def jid=(jid : String) #

[View source]
def jid? : String | Nil #

def logger #

[View source]
def logger=(logger : Log) #

[View source]
def logger? : Log | Nil #