Changes.md
Sidekiq Changes | Sidekiq Pro Changes | Sidekiq Enterprise Changes
web/locales are now manually parsed.
Sidekiq::CLI will now only require YAML if you use a -C .yml file.kiq, Sidekiq's official terminal UI:bundle exec kiq
Use REDIS_URL or REDIS_PROVIDER to point kiq to Redis.
SortedSet#each caused it to miss half of the jobs [#6936]require 'sidekiq/testing' and
require 'sidekiq/testing/inline'.
Add new Sidekiq.testing!(mode) API [#6931]
Requiring code should not enable process-wide changes.# Old, implicit
require "sidekiq/testing"
require "sidekiq/testing/inline"
# New, more explicit
Sidekiq.testing!(:fake)
Sidekiq.testing!(:inline)
retry_for and retry are now mutually exclusive [#6878, Saidbek]perform_inline now enforces strict_args! [#6718, Saidbek]Sec-Fetch-Site header [#6874, deve1212]assets_path for CDN purposes [#6865, stanhu]Sidekiq.configure_server do |cfg|
cfg.reap_idle_redis_connections(60)
end
Sidekiq::Process API to provide capsule data. The queues and weights
data will be removed from Redis in Sidekiq 8.1, as this data can now be found in the
capsules element. [#6295]docs/sdlc.md) and security (docs/SECURITY.md) policy
documentation for Sidekiq's current workflowsSidekiq.configure_server do |cfg|
cfg[:max_iteration_runtime] = 600 # ten minutes
end
discarded_at attribute when discarding a job so death handlers can distinguish between
a job which was killed and one that was discarded. [#6820, gstokkink]perform_bulk now accepts an :at array of times to schedule each job at the corresponding time.
perform_bulk(args: [[1], [2]], at: [Time.now, Time.now + 1]) [#6790, fatkodima]perform_bulk now accepts a :spread_interval value to schedule jobs over
the next N seconds. perform_bulk(..., spread_interval: 60) [#6792, fatkodima]:discard option for sidekiq_retries_exhausted and sidekiq_retry_in
now calls death handlers, otherwise it could break other Sidekiq
functionality. [#6741]current_object for easy access within the around_iteration callback [#6774]after_all_transactions_commit when available. [#6765, rewritten]:exit [#6764]stopping? method to AJ adapter for compatibility with the new AJ::Continuations feature [#6732]on(:exit) event to run code right before the Sidekiq process exits [#6637]ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper to Sidekiq::ActiveJob::Wrapper.
The old name will still work in 8.x.created_at, enqueued_at, failed_at and retried_at attributes are now stored as epoch milliseconds, rather than epoch floats.
This is meant to avoid precision issues with JSON and JavaScript's 53-bit Floats.
Example: "created_at" => 1234567890.123456 -> "created_at" => 1234567890123.ActiveJob::Arguments to serialize the context object, supporting Symbols and GlobalID.
The change should be backwards compatible. [#6510]Sidekiq::Web to simplify the code and improve security [#6532]
The CSS has been rewritten from scratch to remove the Bootstrap framework.on_cancel callback for iterable jobs [#6607]cursor reader to get the current cursor inside iterable jobs [#6606]Exception#detailed_message and #full_message APIs.Logger#with_level, remove Sidekiq's custom implbase64 gem dependencyconfig.redis = { password: ->(username) { "password" } }uninitialized constant Sidekiq::ActiveJob if you
require 'sidekiq' before require 'rails'.Sidekiq::Web.configure for compatibility with 8.0 [#6532]url_params(key) and route_params(key) for compatibility with 8.0 [#6532]inspect for internal S::Components to keep size managable [#6553]retry_all and kill_all API methods to use ZPOPMIN,
approximately 30-60% faster. [#6481]examples/testing/sidekiq_boot to verify your Rails app boots correctly with Sidekiq Enterprise's app preloading.-t timeout setting (defaults to 25 seconds)arguments method:def on_stop
p arguments # => `[123, "string", {"key" => "value"}]`
id, str, hash = arguments
end
Sidekiq::Client#cancel!:c = Sidekiq::Client.new
jid = c.push("class" => SomeJob, "args" => [123])
c.cancel!(jid) # => true
:sidekiq adapter [#6430, fatkodima]Sidekiq.gem_version API.Hash#except [#6376]Sidekiq::IterableJob, iteration support for long-running jobs. [#6286, fatkodima]
Iterable jobs are interruptible and can restart quickly if
running during a deploy. You must ensure that each_iteration
doesn't take more than Sidekiq's -t timeout (default: 25 seconds). Iterable jobs must not implement perform.class ProcessArrayJob
include Sidekiq::IterableJob
def build_enumerator(*args, **kwargs)
array_enumerator(args, **kwargs)
end
def each_iteration(arg)
puts arg
end
end
ProcessArrayJob.perform_async(1, 2, 3)
See the Iteration wiki page and the RDoc in Sidekiq::IterableJob.
This feature should be considered BETA until the next minor release.
<script>.
Adjust CSP to disallow inline scripts within the Web UI. Please see
examples/webui-ext for how to register Web UI extensions and use
dynamic CSS and JS. This will make Sidekiq immune to XSS attacks. [#6270]:skip_default_job_logging to disable Sidekiq's default
start/finish job logging. [#6200]Sidekiq::Limiter.redis to use Redis Cluster [#6288]logger as a dependency since it will become bundled in Ruby 3.5 [#6320]Process.warmup call in Ruby 3.3+Sidekiq::Work type which replaces the raw Hash as the third parameter in
Sidekiq::WorkSet#each { |pid, tid, hash| ... } [#6145]hash block parameter above.
The Sidekiq::Work instance contains accessor methods to get at the same data, e.g.work["queue"] # Old
work.queue # New
base64 gem [#6151, earlopain]sidekiq_retries_exhausted can return :discard to avoid the deadset
and all death handlers [#6091]Sidekiq::Testing.inline! # global setting
Sidekiq::Testing.fake! do # override within block
# ok
Sidekiq::Testing.inline! do # can't override the override
# not ok, nested
end
end
method_missing [#6083]
This can result in app code breaking if your app's Redis API usage was
depending on Sidekiq's adapter to correct invalid redis-client API usage.
One example:# bad, not redis-client native
# Unsupported command argument type: TrueClass (TypeError)
Sidekiq.redis { |c| c.set("key", "value", nx: true, ex: 15) }
# good
Sidekiq.redis { |c| c.set("key", "value", "nx", "ex", 15) }
->(ex, context, config).
The previous calling convention will work until Sidekiq 8.0 but will print
out a deprecation warning. [#6051]batch_size and at options in S::Client.push_bulk [#6040]protocol: 2 [#6061]retry_for logic [#6035]sidekiq_options retry_for: 48.hours to allow time-based retry windows [#6029]enqueued_at from scheduled ActiveJobs [#5937]push_bulk to push batch_size jobs at a time and allow laziness [#5827, fatkodima]
This allows Sidekiq::Client to push unlimited jobs as long as it has enough memory for the batch_size.perform_bulk to use push_bulk internally.push_bulk to map 1-to-1 with arguments.
If you call push_bulk(args: [[1], [2], [3]]), you will now always get
an array of 3 values as the result: ["jid1", nil, "jid3"] where nil means
that particular job did not push successfully (possibly due to middleware
stopping it). Previously nil values were removed so it was impossible to tell
which jobs pushed successfully and which did not.period input parameter on Metrics pages.
Specially crafted values can lead to XSS. This functionality
was introduced in 7.0.4. Thank you to spercex @ huntr.dev [#5694]sidekiq_retry_in block.sidekiq_retry_in [#5806]-v [#5822]sidekiqmon [#5733]size: X for configuring the default Redis pool size [#5702]Sidekiq::Web.custom_job_info_rows << AddAccountLink.new
class AddAccountLink
include CGI::Util
def add_pair(job)
# yield a (name, value) pair
# You can include HTML tags and CSS, Sidekiq does not do any
# escaping so beware user data injection! Note how we use CGI's
# `h` escape helper.
aid = job["account_id"]
yield "Account", "<a href='/accounts/#{h aid}'>#{h aid}</a>" if aid
end
end
docs/7.0-Upgrade.md for release notesContext column on queue page which shows any CurrentAttributes [#5450]sidekiq_retry_in may now return :discard or :kill to dynamically stop job retries [#5406]Redis.exists_returns_integer = false flag. [#5394]push_bulk breakage [#5387]redis-client gem. This will become the default Redis driver in Sidekiq 7.0. [#5298]
Read more: https://github.com/sidekiq/sidekiq/wiki/Using-redis-clientafter_commit_everywhere gem to your Gemfile.Sidekiq.transactional_push!
This feature does not have a lot of production usage yet; please try it out and let us know if you have any issues. It will be fully supported in Sidekiq 7.0 or removed if it proves problematic.
Sidekiq::DEFAULT_WORKER_OPTIONS -> Sidekiq.default_job_options
Sidekiq.default_worker_options -> Sidekiq.default_job_options
Sidekiq::Queues["default"].jobs_by_worker(HardJob) -> Sidekiq::Queues["default"].jobs_by_class(HardJob)
perform_bulk [#5129]perform_async.
Add Sidekiq.strict_args!(false) to your initializer to disable this warning.
This warning will switch to an exception in Sidekiq 7.0.perform_{inline,sync} in Sidekiq::Job to run a job synchronously [#5061, hasan-ally]SomeJob.perform_async(args...)
SomeJob.perform_sync(args...)
SomeJob.perform_inline(args...)
You can also dynamically redirect a job to run synchronously:
SomeJob.set("sync": true).perform_async(args...) # will run via perform_inline
app/workers generator with Sidekiq::Job app/sidekiq generator [#5055]bin/rails generate sidekiq:job ProcessOrderJob
Rails.logger
output in jobs now shows up in the Sidekiq console. Remove any logger
hacks in your initializer and see if it Just Works™ now. [#5021]Sidekiq::Job alias for Sidekiq::Worker, to better
reflect industry standard terminology. You can now do this:class MyJob
include Sidekiq::Job
sidekiq_options ...
def perform(args)
end
end
# config/initializers/sidekiq.rb
require "sidekiq/middleware/current_attributes"
Sidekiq::CurrentAttributes.persist(Myapp::Current) # Your AS::CurrentAttributes singleton
Sidekiq::Worker.perform_bulk for enqueuing jobs in bulk,
similar to Sidekiq::Client.push_bulk [#5042]MyJob.perform_bulk([[1], [2], [3]])
queue_as, wait and wait_until for ActiveJob compatibility [#5003]UNBLOCKED Redis error [#4985]sidekiq_retry_in values [#4957]Cache-Control header [#4966]Sidekiq::Job to Sidekiq::JobRecord [#4955]Sidekiq::Web needs a valid Rack session for CSRF protection. If this is a Rails app,
make sure you mount Sidekiq::Web *inside* your routes in `config/routes.rb` so
Sidekiq can reuse the Rails session:
Rails.application.routes.draw do
mount Sidekiq::Web => "/sidekiq"
....
end
If this is a bare Rack app, use a session middleware before Sidekiq::Web:
# first, use IRB to create a shared secret key for sessions and commit it
require 'securerandom'; File.open(".session.key", "w") {|f| f.write(SecureRandom.hex(32)) }
# now, update your Rack app to include the secret with a session cookie middleware
use Rack::Session::Cookie, secret: File.read(".session.key"), same_site: true, max_age: 86400
run Sidekiq::Web
If this is a Rails app in API mode, you need to enable sessions.
https://guides.rubyonrails.org/api_app.html#using-session-middlewares
Rack::ContentLength is loaded as middleware for correct Web UI responses [#4541]Type=notify in sidekiq.service. The integration works automatically.setTimeout rather than setInterval to avoid thundering herd [#4480]UNLINK, not DEL. [#4449]APP_ENV [95fa5d9]sidekiq_options integration [#4404]Sidekiq::Client.push_bulk API which was erroneously putting
invalid at values in the job payloads [#4321]MyWorker.set(log_level: :debug).perform_async(...)
class MyWorker
include Sidekiq::Worker
sidekiq_options tags: ['bank-ops', 'alpha']
...
end
ScheduledSet with 10,000 jobs
Before: 56.6 seconds
After: 39.2 seconds
RetrySet with 100,000 jobs
Before: 261 MB
After: 129 MB
SortedSet#scan for pattern based scanning. For large sets this API will be MUCH faster
than standard iteration using each. [fatkodima, #4262] Sidekiq::DeadSet.new.scan("UnreliableApi") do |job|
job.retry
end
zscan 0.179366 0.047727 0.227093 ( 1.161376)
enum 8.522311 0.419826 8.942137 ( 9.785079)
test_framework option and gracefully handle extra worker suffix on generator [fatkodima, #4256]Client.push_bulk with different delays [fatkodima, #4243]Sidekiq::Client.push_bulk("class" => FooJob, "args" => [[1], [2]], "at" => [1.minute.from_now.to_f, 5.minutes.from_now.to_f])
assert_equal 1, Sidekiq::Extensions::DelayedMailer.jobs_for(FooMailer).size
sidekiqmon to gemspec executables [#4242]Sidekiq.logger = nil [#4240]This release has major breaking changes. Read and test carefully in production.
sidekiq_options directly to configure Sidekiq
features/internals like the retry subsystem. [#4213, pirj]class MyJob < ActiveJob::Base
queue_as :myqueue
sidekiq_options retry: 10, backtrace: 20
def perform(...)
end
end
Sidekiq.configure_server do |config|
config.log_formatter = Sidekiq::Logger::Formatters::JSON.new
end
See the Logging wiki page for more details.
REDIS_PROVIDER
variable. This variable is meant to hold the name of the environment
variable which contains your Redis URL, so that you can switch Redis
providers quickly and easily with a single variable change. It is not
meant to hold the actual Redis URL itself. If you want to manually set
the Redis URL (not recommended as it implies you have no failover),
then you may set REDIS_URL directly. [#3969]-t 8 to
get the old behavior. [#3968]exists? for redis-rb.sidekiqctlenqueued_at when retrying [#4149]Sidekiq::Worker#set to be chainedconfig/sidekiq.yml [#4077, Tensho]sidekiqctl status command [#4003, dzunk]retry: false now go through the global death_handlers,
meaning you can take action on failed ephemeral jobs. [#3980, Benjamin-Dobell]freeze calls on String constants. This is superfluous with Ruby
2.3+ and frozen_string_literal: true. [#3759]sidekiq_retry_in block can now return nil or 0 to use
the default backoff delay [#3796, dsalahutdinov]Sidekiq::Client.via reentrant [#3715]constantize to better match Rails class lookup. [#3701, caffeinated-tech]Sidekiq::Job#display_args to avoid mutation [#3621]class_attribute core extension from ActiveSupport with Sidekiq one [PikachuEXE, #3499]class_attribute core extension to avoid warningsjob_hash_context from Sidekiq::Logging to support log customizationSidekiq::Middleware::Server::RetryJobs -> Sidekiq::JobRetry
Sidekiq::Middleware::Server::Logging -> Sidekiq::JobLogger
delay extension APIs are no longer available by default, you
must opt into them.SomeWorker.set(options) API was re-written to avoid thread-local state. [#2152]retry default if job payload does not have a retry
attribute [#3234, mlarraz]Sidekiq::Web.set :sessions, false
RAILS_MAX_THREADS env var. [#2985]
This is the same var used by Puma so you can tune all of your systems
the same way:web: RAILS_MAX_THREADS=5 bundle exec puma ...
worker: RAILS_MAX_THREADS=10 bundle exec sidekiq ...
Using -c or config/sidekiq.yml overrides this setting. I recommend
adjusting your config/database.yml to use it too so connections are
auto-scaled:
pool: <%= ENV['RAILS_MAX_THREADS'] || 5 %>
# To clean up lingering processes, modify this as necessary to connect to your Redis.
# After 60 seconds, lingering processes should disappear from the Busy page.
require 'redis'
r = Redis.new(url: "redis://localhost:6379/0")
# uncomment if you need a namespace
#require 'redis-namespace'
#r = Redis::Namespace.new("foo", r)
r.smembers("processes").each do |pro|
r.expire(pro, 60)
r.expire("#{pro}:workers", 60)
end
$ redis-cli keys "*:workers" | while read LINE ; do TTL=`redis-cli expire "$LINE" 60`; echo "$LINE"; done;
Please note that keys can be dangerous to run on a large, busy Redis. Caveat runner.
Sidekiq.configure_server do |config|
config.default_retries_exhausted = -> (job, ex) do
Sidekiq.logger.info "#{job['class']} job is now dead"
end
end
class MyWorker
include Sidekiq::Worker
sidekiq_retries_exhausted do |job, exception|
end
end
set(options) method allowing
you to override worker options dynamically. This should make it
even easier to switch between ActiveJob and Sidekiq's native APIs [#2780]class MyWorker
include Sidekiq::Worker
sidekiq_options queue: 'default', retry: true
def perform(*args)
# do something
end
end
MyWorker.set(queue: 'high', retry: false).perform_async(1)
json gem dependency from gemspec. [#2743]Sidekiq::Queues namespace. All
assertions made against the Worker class still work as expected.
[#2676, brandonhilkert]assert_equal 0, Sidekiq::Queues["default"].size
HardWorker.perform_async("log")
assert_equal 1, Sidekiq::Queues["default"].size
assert_equal "log", Sidekiq::Queues["default"].first['args'][0]
Sidekiq::Queues.clear_all
sidekiq_retry_in,
allowing you to retry more frequently for certain types of errors.
[#2619, kreynolds] sidekiq_retry_in do |count, ex|
case ex
when RuntimeError
5 * count
else
10 * count
end
end
Sidekiq::Worker in ActiveJob::Base classes. [#2424]use Rack::Session::Cookie, :secret => "some unique secret string here"
created_at attribute when jobs are created, set enqueued_at only
when they go into a queue. Fixes invalid latency calculations with scheduled jobs.
[#2373, mrsimo]shutdown event handlers in reverse order of definition [#2374]poll_interval to be simpler, more predictable [#2317, cainlevy]
The new setting is average_scheduled_poll_interval. To configure
Sidekiq to look for scheduled jobs every 5 seconds, just set it to 5.Sidekiq.configure_server do |config|
config.average_scheduled_poll_interval = 5
end
sidekiqctl.Sidekiq::Logging.with_context is now a stack so you can set your
own job context for logging purposes [grosser, #2110]rails g sidekiq:worker User will create app/workers/user_worker.rb. [seuros, #1909]Sidekiq::Web.app_url = 'http://www.mysite.com' [#1875, seuros]-g tag) to the Busy page so you can differentiate processes at a glance. [seuros, #1878]Bundler.require(:default, environment) to boot all gems
before loading any app code.namespace :sidekiq do
task :quiet => :environment do
Sidekiq::ProcessSet.new.each(&:quiet!)
end
end
Sidekiq::Extensions::Delay*
classes, instead showing Class.method as the Job. [#1718]Sidekiq.remove_delay! in your initializer. [devaroop, #1674]dead option.sidekiq_options :dead => false, :retry => 5
Please see 3.0-Upgrade.md for more comprehensive upgrade notes.
sidekiq_options :retry => false if you
don't wish jobs to be retried or put in the DJQ. Use
sidekiq_options :retry => 0 if you don't want jobs to retry but go
straight to the DJQ.Sidekiq.configure_server do |config|
config.on(:startup) do
# do something
end
end
Sidekiq.configure_server do |config|
config.error_handlers << proc {|ex,ctx| ... }
end
client = Sidekiq::Client.new(ConnectionPool.new { Redis.new })
client.push(...)
Sidekiq::Client.via(ConnectionPool.new { Redis.new }) do
FooWorker.perform_async
BarWorker.perform_async
end
Sharding support does require a breaking change to client-side middleware, see docs/3.0-Upgrade.md.
heroku config:set REDIS_PROVIDER=REDISTOGO_URLconfig/sidekiq.yml, if not passed -C. [#1481]USR2 signal will now reopen all logs, using IO#reopen. Thus, instead of creating a new Logger object,
Sidekiq will now just update the existing Logger's file descriptor [#1163].-P [#1470]sidekiq -q critical,default,low,
you must now use the -q flag before each queue, e.g.
sidekiq -q critical -q default -q low.delay extension as sidekiq_delay also. This allows you to
run Delayed::Job and Sidekiq in the same process, selectively porting
delay calls to sidekiq_delay. You just need to ensure that
Sidekiq is required before Delayed::Job in your Gemfile. [#1393]Sidekiq::Client#push_bulk to return an array of pushed jids. [#1315, barelyknown]resolv-replace. MRI's native DNS lookup releases the GIL.Sidekiq::Client.registered_workers and Sidekiq::Client.registered_queuesresolv-replace to enable pure Ruby DNS lookups.
This ensures that any DNS resolution that takes place in worker
threads won't lock up the entire VM on MRI. [#1258]inline and fake behavior in your tests. See
Testing for detail. [#1193]Sidekiq.default_worker_options = { 'queue' => 'default', 'backtrace' => true }
enqueue_to_in and enqueue_in [#1212]Sidekiq::Middleware::Server::RetryJobs middleware. [czarneckid] [#1091]Sidekiq.configure_server do |config|
config.server_middleware do |chain|
chain.add Sidekiq::Middleware::Server::RetryJobs, :max_retries => 10
end
end
class MyWorker
include Sidekiq::Worker
sidekiq_retry_in { |count| count * 2 }
end
class MyWorker
include Sidekiq::Worker
sidekiq_retries_exhausted do |msg|
Rails.logger.error "Failed to process #{msg['class']} with args: #{msg['args']}"
end
end
At this point, if you are experiencing stability issues with Sidekiq in Ruby 1.9, please try Ruby 2.0. It seems to be more stable.
perform_one that dequeues and performs a single job.
This is mainly to aid testing jobs that spawn other jobs. [fumin, #963]multi_json as json is now robust on all platforms.sidekiq_options. Ruby's timeout
is inherently unsafe in a multi-threaded application and was causing
stability problems for many. See http://bit.ly/OtYpKfind_job method to sidekiq/apiweb/locales/en.yml for
your own language. [#811]require 'sidekiq/middleware/i18n' in your sidekiq initializer. [#750]sidekiq_redis = { :url => 'redis://localhost:3679', :namespace => 'foo' }
Sidekiq.configure_server { |config| config.redis = sidekiq_redis }
Sidekiq.configure_client { |config| config.redis = sidekiq_redis }
A warning is printed out to the log if a namespace is found in your sidekiq.yml.
ruby-prof with -p. When Sidekiq is stopped
via Ctrl-C, it will output profile.html. You must add gem 'ruby-prof' to your Gemfile for it to work.workers = Sidekiq::Workers.new
workers.size => 2
workers.each do |name, work|
# name is a unique identifier per Processor instance
# work is a Hash which looks like:
# { 'queue' => name, 'run_at' => timestamp, 'payload' => msg }
end
---
:concurrency: 50
:verbose: false
staging:
:verbose: true
:concurrency: 5
retry_queue option so retries can be given lower priority [ryanlower, #620]sidekiq_options queue: 'high', retry_queue: 'low'
insert_before and insert_after for fine
tuning the order of middleware. [jackrg, #595]Sidekiq::Client.push now accepts the worker class as a string so the
Sidekiq client does not have to load your worker classes at all. [#524]Sidekiq::Client.push_bulk now works with inline testing.delay_until so you can delay jobs until a specific timestamp:Auction.delay_until(@auction.ends_at).close(@auction.id)
This is identical to the existing Sidekiq::Worker method, perform_at.
Remove asset pipeline from Web UI for much faster, simpler runtime. [#499, #490, #481]
Add -g option so the procline better identifies a Sidekiq process, defaults to File.basename(Rails.root). [#486]
sidekiq 2.5.1 myapp [0 of 25 busy]
Add splay to retry time so groups of failed jobs don't fire all at once. [#483]
Foo.delay(:retry => false).bar
Foo.delay(:retry => 10).bar
Foo.delay(:timeout => 10.seconds).bar
Foo.delay_for(5.minutes, :timeout => 10.seconds).bar
Airbrake#notify_or_ignoreSomeClass.delay.class_method(1, 'mike', Date.today)
Add "Clear Workers" button to UI. If you kill -9 Sidekiq, the workers set can fill up with stale entries.
Update sidekiq/testing to support new scheduled jobs API:
require 'sidekiq/testing'
DirectWorker.perform_in(10.seconds, 1, 2)
assert_equal 1, DirectWorker.jobs.size
assert_in_delta 10.seconds.from_now.to_f, DirectWorker.jobs.last['at'], 0.01
You can now use perform_at and perform_in to schedule jobs
to run at arbitrary points in the future, like so:
SomeWorker.perform_in(5.days, 'bob', 13)
SomeWorker.perform_at(5.days.from_now, 'bob', 13)
It also works with the delay extensions:
UserMailer.delay_for(5.days).send_welcome_email(user.id)
The time is approximately when the job will be placed on the queue; it is not guaranteed to run at precisely at that moment in time.
This functionality is meant for one-off, arbitrary jobs. I still
recommend whenever or clockwork if you want cron-like,
recurring jobs. See examples/scheduling.rb
I want to specially thank @yabawock for his work on sidekiq-scheduler. His extension for Sidekiq 1.x filled an obvious functional gap that I now think is useful enough to implement in Sidekiq proper.
class Worker
include Sidekiq::Worker
sidekiq_options :backtrace => [true || 10]
end
class HangingWorker
include Sidekiq::Worker
sidekiq_options :timeout => 600
def perform
# will be killed if it takes longer than 10 minutes
end
end
#drain class method to workers. This method
executes all previously queued jobs. (panthomakos)require 'sidekiq/testing/inline' (panthomakos)bundle_cmd if set [#147]Sidekiq.configure_client do |config|
require 'sidekiq/middleware/client/unique_jobs'
config.client_middleware do |chain|
chain.add Sidekiq::Middleware::Client::UniqueJobs
end
end
Sidekiq.configure_server do |config|
require 'sidekiq/middleware/server/unique_jobs'
config.server_middleware do |chain|
chain.add Sidekiq::Middleware::Server::UniqueJobs
end
end
Thanks to all Sidekiq users and contributors for helping me get to this big milestone!
delay extensions for ActionMailer and ActiveRecord. (mperham)