- Defined in:
#push(item) ⇒ Object
The main method used to push a job to Redis. Accepts a number of options:
queue - the named queue to use, default 'default' class - the worker class to call, required args - an array of simple arguments to the perform method, must be JSON-serializable at - timestamp to schedule the job (optional), must be Numeric (e.g. Time.now.to_f) retry - whether to retry this job if it fails, default true or an integer number of retries backtrace - whether to save any error backtrace, default false
If class is set to the class name, the jobs' options will be based on Sidekiq's default worker options. Otherwise, they will be based on the job class's options.
Any options valid for a worker class's sidekiq_options are also available here.
All options must be strings, not symbols. NB: because we are serializing to JSON, all symbols in 'args' will be converted to strings. Note that backtrace: true can take quite a bit of space in Redis; a large volume of failing jobs can start Redis swapping if you aren't careful.
Returns a unique Job ID. If middleware stops the job, nil will be returned instead.
push('queue' => 'my_queue', 'class' => MyWorker, 'args' => ['foo', 1, :bat => 'bar'])
69 70 71 72 73 74 75 76 77
# File 'lib/sidekiq/client.rb', line 69 def push(item) normed = normalize_item(item) payload = process_single(item['class'], normed) if payload raw_push([payload]) payload['jid'] end end