-
Notifications
You must be signed in to change notification settings - Fork 74
Workers
Mike Perham edited this page Jul 11, 2016
·
5 revisions
In Sidekiq, a Worker is a class that executes jobs based on the arguments passed into its perform
method.
class MyWorker
include Sidekiq::Worker
def perform(user_id : Int64, email : String)
# do something
end
end
You create a job using the async API:
jid = MyWorker.async.perform(123_i64, "[email protected]")
You'll get back a JID, a unique identifier for every job you create.
You can configure the properties of a job using the block form of async
:
jid = MyWorker.async do |job|
job.queue = "foo"
job.retry = false
end.perform(123_i64, "[email protected]")
Sidekiq.cr does not currently support Sidekiq.rb's sidekiq_options
API, the dynamic nature of the keys and values are tough to support in Crystal, but help is welcome.