module Sidekiq::Worker::ClassMethods
Public Instance Methods
# File lib/sidekiq/worker.rb, line 268 def delay(*args) raise ArgumentError, "Do not call .delay on a Sidekiq::Worker class, call .perform_async" end
# File lib/sidekiq/worker.rb, line 272 def delay_for(*args) raise ArgumentError, "Do not call .delay_for on a Sidekiq::Worker class, call .perform_in" end
# File lib/sidekiq/worker.rb, line 276 def delay_until(*args) raise ArgumentError, "Do not call .delay_until on a Sidekiq::Worker class, call .perform_at" end
# File lib/sidekiq/worker.rb, line 288 def perform_async(*args) Setter.new(self, {}).perform_async(*args) end
Push a large number of jobs to Redis, while limiting the batch of each job payload to 1,000. This method helps cut down on the number of round trips to Redis, which can increase the performance of enqueueing large numbers of jobs.
items
must be an Array of Arrays.
For finer-grained control, use `Sidekiq::Client.push_bulk` directly.
Example (3 Redis round trips):
SomeWorker.perform_async(1) SomeWorker.perform_async(2) SomeWorker.perform_async(3)
Would instead become (1 Redis round trip):
SomeWorker.perform_bulk([[1], [2], [3]])
# File lib/sidekiq/worker.rb, line 318 def perform_bulk(*args, **kwargs) Setter.new(self, {}).perform_bulk(*args, **kwargs) end
interval
must be a timestamp, numeric or something that acts
numeric (like an activesupport time interval).
# File lib/sidekiq/worker.rb, line 324 def perform_in(interval, *args) int = interval.to_f now = Time.now.to_f ts = ((int < 1_000_000_000) ? now + int : int) item = {"class" => self, "args" => args} # Optimization to enqueue something now that is scheduled to go out now or in the past item["at"] = ts if ts > now client_push(item) end
Inline execution of job's perform method after passing through Sidekiq.client_middleware
and Sidekiq.server_middleware
# File lib/sidekiq/worker.rb, line 293 def perform_inline(*args) Setter.new(self, {}).perform_inline(*args) end
# File lib/sidekiq/worker.rb, line 280 def queue_as(q) sidekiq_options("queue" => q.to_s) end
# File lib/sidekiq/worker.rb, line 284 def set(options) Setter.new(self, options) end
Allows customization for this type of Worker
. Legal options:
queue - use a named queue for this Worker, default 'default' retry - enable retries via JobRetry, *true* to use the default or *Integer* count backtrace - whether to save any error backtrace in the retry payload to display in web UI, can be true, false or an integer number of lines to save, default *false* pool - use the given Redis connection pool to push this type of job to a given shard.
In practice, any option is allowed. This is the main mechanism to configure the options for a specific job.
These options will be saved into the serialized job when enqueued by the client.
# File lib/sidekiq/worker.rb, line 354 def sidekiq_options(opts = {}) super end