mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Merge branch 'master' into rails5
This commit is contained in:
commit
eca6424e98
26 changed files with 280 additions and 88 deletions
0
Contributing.md → .github/contributing.md
vendored
0
Contributing.md → .github/contributing.md
vendored
|
@ -3,6 +3,9 @@ sudo: false
|
||||||
cache: bundler
|
cache: bundler
|
||||||
services:
|
services:
|
||||||
- redis-server
|
- redis-server
|
||||||
|
before_install:
|
||||||
|
- gem install bundler
|
||||||
|
- gem update bundler
|
||||||
rvm:
|
rvm:
|
||||||
- 2.2.4
|
- 2.2.4
|
||||||
- 2.3.0
|
- 2.3.0
|
||||||
|
|
|
@ -28,7 +28,7 @@ In order to use the Software under this Agreement, you must receive a “Source
|
||||||
|
|
||||||
3.1 You shall not (and shall not allow any third party to): (a) decompile, disassemble, or otherwise reverse engineer the Software or attempt to reconstruct or discover any source code, underlying ideas, algorithms, file formats or programming interfaces of the Software by any means whatsoever (except and only to the extent that applicable law prohibits or restricts reverse engineering restrictions); (b) distribute, sell, sublicense, rent, lease or use the Software for time sharing, hosting, service provider or like purposes, except as expressly permitted under this Agreement; (c) redistribute the Software or Modifications other than by including the Software or a portion thereof within your own product, which must have substantially different functionality than the Software or Modifications and must not allow any third party to use the Software or Modifications, or any portions thereof, for software development or application development purposes; (d) redistribute the Software as part of a product, "appliance" or "virtual server"; (e) redistribute the Software on any server which is not directly under your control; (f) remove any product identification, proprietary, copyright or other notices contained in the Software; (g) modify any part of the Software, create a derivative work of any part of the Software (except as permitted in Section 4), or incorporate the Software, except to the extent expressly authorized in writing by Contributed Systems; (h) publicly disseminate performance information or analysis (including, without limitation, benchmarks) from any source relating to the Software; (i) utilize any equipment, device, software, or other means designed to circumvent or remove any form of Source URL or copy protection used by Contributed Systems in connection with the Software, or use the Software together with any authorization code, Source URL, serial number, or other copy protection device not supplied by Contributed Systems; (j) use the Software to develop a product which is competitive with any Contributed Systems product offerings; or (k) use unauthorized Source URLS or keycode(s) or distribute or publish Source URLs or keycode(s), except as may be expressly permitted by Contributed Systems in writing. If your unique Source URL is ever published, Contributed Systems reserves the right to terminate your access without notice.
|
3.1 You shall not (and shall not allow any third party to): (a) decompile, disassemble, or otherwise reverse engineer the Software or attempt to reconstruct or discover any source code, underlying ideas, algorithms, file formats or programming interfaces of the Software by any means whatsoever (except and only to the extent that applicable law prohibits or restricts reverse engineering restrictions); (b) distribute, sell, sublicense, rent, lease or use the Software for time sharing, hosting, service provider or like purposes, except as expressly permitted under this Agreement; (c) redistribute the Software or Modifications other than by including the Software or a portion thereof within your own product, which must have substantially different functionality than the Software or Modifications and must not allow any third party to use the Software or Modifications, or any portions thereof, for software development or application development purposes; (d) redistribute the Software as part of a product, "appliance" or "virtual server"; (e) redistribute the Software on any server which is not directly under your control; (f) remove any product identification, proprietary, copyright or other notices contained in the Software; (g) modify any part of the Software, create a derivative work of any part of the Software (except as permitted in Section 4), or incorporate the Software, except to the extent expressly authorized in writing by Contributed Systems; (h) publicly disseminate performance information or analysis (including, without limitation, benchmarks) from any source relating to the Software; (i) utilize any equipment, device, software, or other means designed to circumvent or remove any form of Source URL or copy protection used by Contributed Systems in connection with the Software, or use the Software together with any authorization code, Source URL, serial number, or other copy protection device not supplied by Contributed Systems; (j) use the Software to develop a product which is competitive with any Contributed Systems product offerings; or (k) use unauthorized Source URLS or keycode(s) or distribute or publish Source URLs or keycode(s), except as may be expressly permitted by Contributed Systems in writing. If your unique Source URL is ever published, Contributed Systems reserves the right to terminate your access without notice.
|
||||||
|
|
||||||
3.2 UNDER NO CIRCUMSTANCES MAY YOU USE THE SOFTWARE FOR A PRODUCT THAT IS INTENDED FOR SOFTWARE OR APPLICATION DEVELOPMENT PURPOSES.
|
3.2 UNDER NO CIRCUMSTANCES MAY YOU USE THE SOFTWARE AS PART OF A PRODUCT OR SERVICE THAT PROVIDES SIMILAR FUNCTIONALITY TO THE SOFTWARE ITSELF.
|
||||||
|
|
||||||
The Open Source version of the Software (“LGPL Version”) is licensed
|
The Open Source version of the Software (“LGPL Version”) is licensed
|
||||||
under the terms of the GNU Lesser General Public License versions 3.0
|
under the terms of the GNU Lesser General Public License versions 3.0
|
||||||
|
|
20
Changes.md
20
Changes.md
|
@ -1,5 +1,25 @@
|
||||||
# Sidekiq Changes
|
# Sidekiq Changes
|
||||||
|
|
||||||
|
4.1.2
|
||||||
|
-----------
|
||||||
|
|
||||||
|
- Client middleware can now stop bulk job push. [#2887]
|
||||||
|
|
||||||
|
4.1.1
|
||||||
|
-----------
|
||||||
|
|
||||||
|
- Much better behavior when Redis disappears and comes back. [#2866]
|
||||||
|
- Update FR locale [dbachet]
|
||||||
|
- Don't fill logfile in case of Redis downtime [#2860]
|
||||||
|
- Allow definition of a global retries_exhausted handler. [#2807]
|
||||||
|
```ruby
|
||||||
|
Sidekiq.configure_server do |config|
|
||||||
|
config.default_retries_exhausted = -> (job, ex) do
|
||||||
|
Sidekiq.logger.info "#{job['class']} job is now dead"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
4.1.0
|
4.1.0
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,15 @@ Sidekiq Enterprise Changelog
|
||||||
|
|
||||||
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
||||||
|
|
||||||
|
1.2.1
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Multi-Process mode can now monitor the RSS memory of children and
|
||||||
|
restart any that grow too large. To limit children to 1GB each:
|
||||||
|
```
|
||||||
|
MAXMEM_KB=1048576 COUNT=2 bundle exec sidekiqswarm ...
|
||||||
|
```
|
||||||
|
|
||||||
1.2.0
|
1.2.0
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,57 @@ Sidekiq Pro Changelog
|
||||||
|
|
||||||
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
||||||
|
|
||||||
|
3.2.1
|
||||||
|
---------
|
||||||
|
|
||||||
|
- timed\_fetch now works with namespaces. [ryansch]
|
||||||
|
|
||||||
|
|
||||||
|
3.2.0
|
||||||
|
---------
|
||||||
|
|
||||||
|
- Fixed detection of missing batches, `NoSuchBatch` should be raised
|
||||||
|
properly now if `Sidekiq::Batch.new(bid)` is called on a batch no
|
||||||
|
longer in Redis.
|
||||||
|
- Remove support for Pro 1.x format batches. This version will no
|
||||||
|
longer seamlessly process batches created with Sidekiq Pro 1.x.
|
||||||
|
As always, upgrade one major version at a time to ensure a smooth
|
||||||
|
transition.
|
||||||
|
- Fix edge case where a parent batch could expire before a child batch
|
||||||
|
was finished processing, leading to missing batches [#2889]
|
||||||
|
|
||||||
|
2.1.5
|
||||||
|
---------
|
||||||
|
|
||||||
|
- Fix edge case where a parent batch could expire before a child batch
|
||||||
|
was finished processing, leading to missing batches [#2889]
|
||||||
|
|
||||||
|
3.1.0
|
||||||
|
---------
|
||||||
|
|
||||||
|
- New container-friendly fetch algorithm: `timed_fetch`. See the
|
||||||
|
[wiki documentation](https://github.com/mperham/sidekiq/wiki/Pro-Reliability-Server)
|
||||||
|
for trade offs between the two reliability options. You should
|
||||||
|
use this if you are on Heroku, Docker, Amazon ECS or EBS or
|
||||||
|
another container-based system.
|
||||||
|
|
||||||
|
|
||||||
|
3.0.6
|
||||||
|
---------
|
||||||
|
|
||||||
|
- Fix race condition on reliable fetch shutdown
|
||||||
|
|
||||||
|
3.0.5
|
||||||
|
---------
|
||||||
|
|
||||||
|
- Statsd metrics now account for ActiveJob class names
|
||||||
|
- Allow reliable fetch internals to be overridden [jonhyman]
|
||||||
|
|
||||||
|
3.0.4
|
||||||
|
---------
|
||||||
|
|
||||||
|
- Queue pausing no longer requires reliable fetch. [#2786]
|
||||||
|
|
||||||
3.0.3, 2.1.4
|
3.0.3, 2.1.4
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|
31
README.md
31
README.md
|
@ -11,7 +11,7 @@ Simple, efficient background processing for Ruby.
|
||||||
|
|
||||||
Sidekiq uses threads to handle many jobs at the same time in the
|
Sidekiq uses threads to handle many jobs at the same time in the
|
||||||
same process. It does not require Rails but will integrate tightly with
|
same process. It does not require Rails but will integrate tightly with
|
||||||
Rails 3/4 to make background processing dead simple.
|
Rails to make background processing dead simple.
|
||||||
|
|
||||||
Sidekiq is compatible with Resque. It uses the exact same
|
Sidekiq is compatible with Resque. It uses the exact same
|
||||||
message format as Resque so it can integrate into an existing Resque processing farm.
|
message format as Resque so it can integrate into an existing Resque processing farm.
|
||||||
|
@ -31,10 +31,9 @@ DelayedJob 4.1.1 | - | - | 465 sec | 215 jobs/sec
|
||||||
Requirements
|
Requirements
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
I test with the latest CRuby (2.2, 2.1 and 2.0) and JRuby versions (9k). Other versions/VMs
|
Sidekiq supports CRuby 2.0+ and JRuby 9k.
|
||||||
are untested but might work fine. CRuby 1.9 is not supported.
|
|
||||||
|
|
||||||
All Rails releases from 3.2 are officially supported.
|
All Rails releases >= 3.2 are officially supported.
|
||||||
|
|
||||||
Redis 2.8 or greater is required. 3.0.3+ is recommended for large
|
Redis 2.8 or greater is required. 3.0.3+ is recommended for large
|
||||||
installations with thousands of worker threads.
|
installations with thousands of worker threads.
|
||||||
|
@ -63,24 +62,30 @@ features, a commercial-friendly license and allow you to support high
|
||||||
quality open source development all at the same time. Please see the
|
quality open source development all at the same time. Please see the
|
||||||
[Sidekiq](http://sidekiq.org/) homepage for more detail.
|
[Sidekiq](http://sidekiq.org/) homepage for more detail.
|
||||||
|
|
||||||
|
Subscribe to the **[quarterly newsletter](https://tinyletter.com/sidekiq)** to stay informed about the latest
|
||||||
|
features and changes to Sidekiq and its bigger siblings.
|
||||||
|
|
||||||
|
|
||||||
Problems?
|
Problems?
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
**Please do not directly email any Sidekiq committers with questions or problems.** A community is best served when discussions are held in public.
|
**Please do not directly email any Sidekiq committers with questions or problems.** A community is best served when discussions are held in public.
|
||||||
|
|
||||||
Please see the [sidekiq wiki](https://github.com/mperham/sidekiq/wiki) for the official documentation.
|
If you have a problem, please review the [FAQ](https://github.com/mperham/sidekiq/wiki/FAQ) and [Troubleshooting](https://github.com/mperham/sidekiq/wiki/Problems-and-Troubleshooting) wiki pages.
|
||||||
[mperham/sidekiq on Gitter](https://gitter.im/mperham/sidekiq) is dedicated to this project,
|
Searching the [issues](https://github.com/mperham/sidekiq/issues) for your problem is also a good idea.
|
||||||
but bug reports or feature requests suggestions should still go through [issues on Github](https://github.com/mperham/sidekiq/issues). Release announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account. **No support via Twitter.**
|
|
||||||
|
|
||||||
Every Friday morning is Sidekiq happy hour: I video chat and answer questions.
|
Useful resources:
|
||||||
|
|
||||||
|
* Product documentation is in the [wiki](https://github.com/mperham/sidekiq/wiki).
|
||||||
|
* Release announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account.
|
||||||
|
* Here's a [Reddit forum](https://reddit.com/r/sidekiq) dedicated to Sidekiq discussion
|
||||||
|
* The [Sidekiq tag](https://stackoverflow.com/questions/tagged/sidekiq) on Stack Overflow has lots of useful Q & A.
|
||||||
|
|
||||||
|
**No support via Twitter, 140 characters is not enough.**
|
||||||
|
|
||||||
|
Every Friday morning 9am Pacific is Sidekiq happy hour: I video chat and answer questions.
|
||||||
See the [Sidekiq support page](http://sidekiq.org/support).
|
See the [Sidekiq support page](http://sidekiq.org/support).
|
||||||
|
|
||||||
You may also find useful a [Reddit area](https://reddit.com/r/sidekiq) dedicated to Sidekiq discussion and [a Sidekiq tag](https://stackoverflow.com/questions/tagged/sidekiq) on Stack Overflow.
|
|
||||||
|
|
||||||
If you have a problem, please review the [FAQ](https://github.com/mperham/sidekiq/wiki/FAQ) and [Troubleshooting](https://github.com/mperham/sidekiq/wiki/Problems-and-Troubleshooting) wiki pages. Searching the issues for your problem is also a good idea. If that doesn't help, feel free to email the Sidekiq mailing list, chat in Gitter, or open a new issue. StackOverflow or Reddit is the preferred place to ask questions on usage. If you are encountering what you think is a bug, please open an issue.
|
|
||||||
|
|
||||||
|
|
||||||
Thanks
|
Thanks
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
require 'sidekiq/version'
|
require 'sidekiq/version'
|
||||||
fail "Sidekiq #{Sidekiq::VERSION} does not support Ruby 1.9." if RUBY_PLATFORM != 'java' && RUBY_VERSION < '2.0.0'
|
fail "Sidekiq #{Sidekiq::VERSION} does not support Ruby versions below 2.0.0." if RUBY_PLATFORM != 'java' && RUBY_VERSION < '2.0.0'
|
||||||
|
|
||||||
require 'sidekiq/logging'
|
require 'sidekiq/logging'
|
||||||
require 'sidekiq/client'
|
require 'sidekiq/client'
|
||||||
|
@ -38,6 +38,14 @@ module Sidekiq
|
||||||
'queue' => 'default'
|
'queue' => 'default'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FAKE_INFO = {
|
||||||
|
"redis_version" => "9.9.9",
|
||||||
|
"uptime_in_days" => "9999",
|
||||||
|
"connected_clients" => "9999",
|
||||||
|
"used_memory_human" => "9P",
|
||||||
|
"used_memory_peak_human" => "9P"
|
||||||
|
}.freeze
|
||||||
|
|
||||||
def self.❨╯°□°❩╯︵┻━┻
|
def self.❨╯°□°❩╯︵┻━┻
|
||||||
puts "Calm down, yo."
|
puts "Calm down, yo."
|
||||||
end
|
end
|
||||||
|
@ -45,7 +53,6 @@ module Sidekiq
|
||||||
def self.options
|
def self.options
|
||||||
@options ||= DEFAULTS.dup
|
@options ||= DEFAULTS.dup
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.options=(opts)
|
def self.options=(opts)
|
||||||
@options = opts
|
@options = opts
|
||||||
end
|
end
|
||||||
|
@ -92,6 +99,24 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.redis_info
|
||||||
|
redis do |conn|
|
||||||
|
begin
|
||||||
|
# admin commands can't go through redis-namespace starting
|
||||||
|
# in redis-namespace 2.0
|
||||||
|
if conn.respond_to?(:namespace)
|
||||||
|
conn.redis.info
|
||||||
|
else
|
||||||
|
conn.info
|
||||||
|
end
|
||||||
|
rescue Redis::CommandError => ex
|
||||||
|
#2850 return fake version when INFO command has (probably) been renamed
|
||||||
|
raise unless ex.message =~ /unknown command/
|
||||||
|
FAKE_INFO
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.redis_pool
|
def self.redis_pool
|
||||||
@redis ||= Sidekiq::RedisConnection.create
|
@redis ||= Sidekiq::RedisConnection.create
|
||||||
end
|
end
|
||||||
|
@ -133,15 +158,24 @@ module Sidekiq
|
||||||
def self.default_worker_options=(hash)
|
def self.default_worker_options=(hash)
|
||||||
@default_worker_options = default_worker_options.merge(hash.stringify_keys)
|
@default_worker_options = default_worker_options.merge(hash.stringify_keys)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.default_worker_options
|
def self.default_worker_options
|
||||||
defined?(@default_worker_options) ? @default_worker_options : DEFAULT_WORKER_OPTIONS
|
defined?(@default_worker_options) ? @default_worker_options : DEFAULT_WORKER_OPTIONS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Sidekiq.configure_server do |config|
|
||||||
|
# config.default_retries_exhausted = -> (job, ex) do
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
def self.default_retries_exhausted=(prok)
|
||||||
|
@default_retries_exhausted = prok
|
||||||
|
end
|
||||||
|
def self.default_retries_exhausted
|
||||||
|
@default_retries_exhausted
|
||||||
|
end
|
||||||
|
|
||||||
def self.load_json(string)
|
def self.load_json(string)
|
||||||
JSON.parse(string)
|
JSON.parse(string)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.dump_json(object)
|
def self.dump_json(object)
|
||||||
JSON.generate(object)
|
JSON.generate(object)
|
||||||
end
|
end
|
||||||
|
@ -149,7 +183,6 @@ module Sidekiq
|
||||||
def self.logger
|
def self.logger
|
||||||
Sidekiq::Logging.logger
|
Sidekiq::Logging.logger
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.logger=(log)
|
def self.logger=(log)
|
||||||
Sidekiq::Logging.logger = log
|
Sidekiq::Logging.logger = log
|
||||||
end
|
end
|
||||||
|
|
|
@ -277,6 +277,7 @@ module Sidekiq
|
||||||
#
|
#
|
||||||
class Job
|
class Job
|
||||||
attr_reader :item
|
attr_reader :item
|
||||||
|
attr_reader :value
|
||||||
|
|
||||||
def initialize(item, queue_name=nil)
|
def initialize(item, queue_name=nil)
|
||||||
@value = item
|
@value = item
|
||||||
|
|
|
@ -65,12 +65,10 @@ module Sidekiq
|
||||||
logger.info Sidekiq::LICENSE
|
logger.info Sidekiq::LICENSE
|
||||||
logger.info "Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org" unless defined?(::Sidekiq::Pro)
|
logger.info "Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org" unless defined?(::Sidekiq::Pro)
|
||||||
|
|
||||||
Sidekiq.redis do |conn|
|
# touch the connection pool so it is created before we
|
||||||
# touch the connection pool so it is created before we
|
# fire startup and start multithreading.
|
||||||
# fire startup and start multithreading.
|
ver = Sidekiq.redis_info['redis_version']
|
||||||
ver = conn.info['redis_version']
|
raise "You are using Redis v#{ver}, Sidekiq requires Redis v2.8.0 or greater" if ver < '2.8'
|
||||||
raise "You are using Redis v#{ver}, Sidekiq requires Redis v2.8.0 or greater" if ver < '2.8'
|
|
||||||
end
|
|
||||||
|
|
||||||
# Before this point, the process is initializing with just the main thread.
|
# Before this point, the process is initializing with just the main thread.
|
||||||
# Starting here the process will now have multiple threads running.
|
# Starting here the process will now have multiple threads running.
|
||||||
|
|
|
@ -82,10 +82,14 @@ module Sidekiq
|
||||||
# Returns an array of the of pushed jobs' jids. The number of jobs pushed can be less
|
# Returns an array of the of pushed jobs' jids. The number of jobs pushed can be less
|
||||||
# than the number given if the middleware stopped processing for one or more jobs.
|
# than the number given if the middleware stopped processing for one or more jobs.
|
||||||
def push_bulk(items)
|
def push_bulk(items)
|
||||||
|
arg = items['args'].first
|
||||||
|
raise ArgumentError, "Bulk arguments must be an Array of Arrays: [[1], [2]]" if !arg.is_a?(Array)
|
||||||
|
|
||||||
normed = normalize_item(items)
|
normed = normalize_item(items)
|
||||||
payloads = items['args'].map do |args|
|
payloads = items['args'].map do |args|
|
||||||
raise ArgumentError, "Bulk arguments must be an Array of Arrays: [[1], [2]]" if !args.is_a?(Array)
|
copy = normed.merge('args' => args, 'jid' => SecureRandom.hex(12), 'enqueued_at' => Time.now.to_f)
|
||||||
process_single(items['class'], normed.merge('args' => args, 'jid' => SecureRandom.hex(12), 'enqueued_at' => Time.now.to_f))
|
result = process_single(items['class'], copy)
|
||||||
|
result ? result : nil
|
||||||
end.compact
|
end.compact
|
||||||
|
|
||||||
raw_push(payloads) if !payloads.empty?
|
raw_push(payloads) if !payloads.empty?
|
||||||
|
@ -106,7 +110,8 @@ module Sidekiq
|
||||||
# you cannot scale any other way (e.g. splitting your app into smaller apps).
|
# you cannot scale any other way (e.g. splitting your app into smaller apps).
|
||||||
def self.via(pool)
|
def self.via(pool)
|
||||||
raise ArgumentError, "No pool given" if pool.nil?
|
raise ArgumentError, "No pool given" if pool.nil?
|
||||||
raise RuntimeError, "Sidekiq::Client.via is not re-entrant" if x = Thread.current[:sidekiq_via_pool] && x != pool
|
current_sidekiq_pool = Thread.current[:sidekiq_via_pool]
|
||||||
|
raise RuntimeError, "Sidekiq::Client.via is not re-entrant" if current_sidekiq_pool && current_sidekiq_pool != pool
|
||||||
Thread.current[:sidekiq_via_pool] = pool
|
Thread.current[:sidekiq_via_pool] = pool
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
|
@ -205,6 +210,7 @@ module Sidekiq
|
||||||
raise(ArgumentError, "Job must be a Hash with 'class' and 'args' keys: { 'class' => SomeWorker, 'args' => ['bob', 1, :foo => 'bar'] }") unless item.is_a?(Hash) && item.has_key?('class'.freeze) && item.has_key?('args'.freeze)
|
raise(ArgumentError, "Job must be a Hash with 'class' and 'args' keys: { 'class' => SomeWorker, 'args' => ['bob', 1, :foo => 'bar'] }") unless item.is_a?(Hash) && item.has_key?('class'.freeze) && item.has_key?('args'.freeze)
|
||||||
raise(ArgumentError, "Job args must be an Array") unless item['args'].is_a?(Array)
|
raise(ArgumentError, "Job args must be an Array") unless item['args'].is_a?(Array)
|
||||||
raise(ArgumentError, "Job class must be either a Class or String representation of the class name") unless item['class'.freeze].is_a?(Class) || item['class'.freeze].is_a?(String)
|
raise(ArgumentError, "Job class must be either a Class or String representation of the class name") unless item['class'.freeze].is_a?(Class) || item['class'.freeze].is_a?(String)
|
||||||
|
#raise(ArgumentError, "Arguments must be native JSON types, see https://github.com/mperham/sidekiq/wiki/Best-Practices") unless JSON.load(JSON.dump(item['args'])) == item['args']
|
||||||
|
|
||||||
normalized_hash(item['class'.freeze])
|
normalized_hash(item['class'.freeze])
|
||||||
.each{ |key, value| item[key] = value if item[key].nil? }
|
.each{ |key, value| item[key] = value if item[key].nil? }
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
require 'time'
|
require 'time'
|
||||||
require 'logger'
|
require 'logger'
|
||||||
|
require 'fcntl'
|
||||||
|
|
||||||
module Sidekiq
|
module Sidekiq
|
||||||
module Logging
|
module Logging
|
||||||
|
@ -46,7 +47,7 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.logger=(log)
|
def self.logger=(log)
|
||||||
@logger = (log ? log : Logger.new('/dev/null'))
|
@logger = (log ? log : Logger.new(File::NULL))
|
||||||
end
|
end
|
||||||
|
|
||||||
# This reopens ALL logfiles in the process that have been rotated
|
# This reopens ALL logfiles in the process that have been rotated
|
||||||
|
|
|
@ -137,11 +137,10 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
|
|
||||||
def retries_exhausted(worker, msg, exception)
|
def retries_exhausted(worker, msg, exception)
|
||||||
logger.debug { "Dropping message after hitting the retry maximum: #{msg}" }
|
logger.debug { "Retries exhausted for job" }
|
||||||
begin
|
begin
|
||||||
if worker.sidekiq_retries_exhausted_block?
|
block = worker.sidekiq_retries_exhausted_block || Sidekiq.default_retries_exhausted
|
||||||
worker.sidekiq_retries_exhausted_block.call(msg, exception)
|
block.call(msg, exception) if block
|
||||||
end
|
|
||||||
rescue => e
|
rescue => e
|
||||||
handle_exception(e, { context: "Error calling retries_exhausted for #{worker.class}", job: msg })
|
handle_exception(e, { context: "Error calling retries_exhausted for #{worker.class}", job: msg })
|
||||||
end
|
end
|
||||||
|
|
|
@ -111,6 +111,7 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def process(work)
|
def process(work)
|
||||||
|
|
|
@ -77,7 +77,9 @@ module Sidekiq
|
||||||
# Most likely a problem with redis networking.
|
# Most likely a problem with redis networking.
|
||||||
# Punt and try again at the next interval
|
# Punt and try again at the next interval
|
||||||
logger.error ex.message
|
logger.error ex.message
|
||||||
logger.error ex.backtrace.first
|
ex.backtrace.each do |bt|
|
||||||
|
logger.error(bt)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -86,6 +88,13 @@ module Sidekiq
|
||||||
def wait
|
def wait
|
||||||
@sleeper.pop(random_poll_interval)
|
@sleeper.pop(random_poll_interval)
|
||||||
rescue Timeout::Error
|
rescue Timeout::Error
|
||||||
|
# expected
|
||||||
|
rescue => ex
|
||||||
|
# if poll_interval_average hasn't been calculated yet, we can
|
||||||
|
# raise an error trying to reach Redis.
|
||||||
|
logger.error ex.message
|
||||||
|
logger.error ex.backtrace.first
|
||||||
|
sleep 5
|
||||||
end
|
end
|
||||||
|
|
||||||
# Calculates a random interval that is ±50% the desired average.
|
# Calculates a random interval that is ±50% the desired average.
|
||||||
|
|
|
@ -57,19 +57,5 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
arr.clear
|
arr.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
def want_a_hertz_donut?
|
|
||||||
# what's a hertz donut?
|
|
||||||
# punch! Hurts, don't it?
|
|
||||||
info = Sidekiq.redis {|c| c.info }
|
|
||||||
if info['connected_clients'].to_i > 1000 && info['hz'].to_i >= 10
|
|
||||||
Sidekiq.logger.warn { "Your Redis `hz` setting is too high at #{info['hz']}. See mperham/sidekiq#2431. Set it to 3 in #{info[:config_file]}" }
|
|
||||||
true
|
|
||||||
else
|
|
||||||
Sidekiq.logger.debug { "Redis hz: #{info['hz']}. Client count: #{info['connected_clients']}" }
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module Sidekiq
|
module Sidekiq
|
||||||
VERSION = "4.1.0"
|
VERSION = "4.1.1"
|
||||||
end
|
end
|
||||||
|
|
|
@ -122,15 +122,7 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
|
|
||||||
def redis_info
|
def redis_info
|
||||||
Sidekiq.redis do |conn|
|
Sidekiq.redis_info
|
||||||
# admin commands can't go through redis-namespace starting
|
|
||||||
# in redis-namespace 2.0
|
|
||||||
if conn.respond_to?(:namespace)
|
|
||||||
conn.redis.info
|
|
||||||
else
|
|
||||||
conn.info
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def root_path
|
def root_path
|
||||||
|
@ -174,7 +166,7 @@ module Sidekiq
|
||||||
|
|
||||||
def display_args(args, truncate_after_chars = 2000)
|
def display_args(args, truncate_after_chars = 2000)
|
||||||
args.map do |arg|
|
args.map do |arg|
|
||||||
h(truncate(to_display(arg)))
|
h(truncate(to_display(arg), truncate_after_chars))
|
||||||
end.join(", ")
|
end.join(", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,5 +22,6 @@ module Myapp
|
||||||
|
|
||||||
# Do not swallow errors in after_commit/after_rollback callbacks.
|
# Do not swallow errors in after_commit/after_rollback callbacks.
|
||||||
config.active_record.raise_in_transactional_callbacks = true
|
config.active_record.raise_in_transactional_callbacks = true
|
||||||
|
config.active_job.queue_adapter = :sidekiq
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,6 +32,23 @@ class TestClient < Sidekiq::Test
|
||||||
assert_equal 24, jid.size
|
assert_equal 24, jid.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'allows middleware to stop bulk jobs' do
|
||||||
|
mware = Class.new do
|
||||||
|
def call(worker_klass,msg,q,r)
|
||||||
|
msg['args'][0] == 1 ? yield : false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
client = Sidekiq::Client.new
|
||||||
|
client.middleware do |chain|
|
||||||
|
chain.add mware
|
||||||
|
end
|
||||||
|
q = Sidekiq::Queue.new
|
||||||
|
q.clear
|
||||||
|
result = client.push_bulk('class' => 'Blah', 'args' => [[1],[2],[3]])
|
||||||
|
assert_equal 1, result.size
|
||||||
|
assert_equal 1, q.size
|
||||||
|
end
|
||||||
|
|
||||||
it 'allows local middleware modification' do
|
it 'allows local middleware modification' do
|
||||||
$called = false
|
$called = false
|
||||||
mware = Class.new { def call(worker_klass,msg,q,r); $called = true; msg;end }
|
mware = Class.new { def call(worker_klass,msg,q,r); $called = true; msg;end }
|
||||||
|
@ -164,6 +181,18 @@ class TestClient < Sidekiq::Test
|
||||||
conn.verify
|
conn.verify
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'allows #via to point to same Redi' do
|
||||||
|
conn = MiniTest::Mock.new
|
||||||
|
conn.expect(:multi, [0, 1])
|
||||||
|
sharded_pool = ConnectionPool.new(size: 1) { conn }
|
||||||
|
Sidekiq::Client.via(sharded_pool) do
|
||||||
|
Sidekiq::Client.via(sharded_pool) do
|
||||||
|
CWorker.perform_async(1,2,3)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
conn.verify
|
||||||
|
end
|
||||||
|
|
||||||
it 'allows #via to point to different Redi' do
|
it 'allows #via to point to different Redi' do
|
||||||
conn = MiniTest::Mock.new
|
conn = MiniTest::Mock.new
|
||||||
conn.expect(:multi, [0, 1])
|
conn.expect(:multi, [0, 1])
|
||||||
|
|
|
@ -7,11 +7,11 @@ class TestRetryExhausted < Sidekiq::Test
|
||||||
class NewWorker
|
class NewWorker
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
class_attribute :exhausted_called, :exhausted_message, :exhausted_exception
|
class_attribute :exhausted_called, :exhausted_job, :exhausted_exception
|
||||||
|
|
||||||
sidekiq_retries_exhausted do |msg, e|
|
sidekiq_retries_exhausted do |job, e|
|
||||||
self.exhausted_called = true
|
self.exhausted_called = true
|
||||||
self.exhausted_message = msg
|
self.exhausted_job = job
|
||||||
self.exhausted_exception = e
|
self.exhausted_exception = e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -19,18 +19,18 @@ class TestRetryExhausted < Sidekiq::Test
|
||||||
class OldWorker
|
class OldWorker
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
class_attribute :exhausted_called, :exhausted_message, :exhausted_exception
|
class_attribute :exhausted_called, :exhausted_job, :exhausted_exception
|
||||||
|
|
||||||
sidekiq_retries_exhausted do |msg|
|
sidekiq_retries_exhausted do |job|
|
||||||
self.exhausted_called = true
|
self.exhausted_called = true
|
||||||
self.exhausted_message = msg
|
self.exhausted_job = job
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup
|
def cleanup
|
||||||
[NewWorker, OldWorker].each do |worker_class|
|
[NewWorker, OldWorker].each do |worker_class|
|
||||||
worker_class.exhausted_called = nil
|
worker_class.exhausted_called = nil
|
||||||
worker_class.exhausted_message = nil
|
worker_class.exhausted_job = nil
|
||||||
worker_class.exhausted_exception = nil
|
worker_class.exhausted_exception = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -96,7 +96,7 @@ class TestRetryExhausted < Sidekiq::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it 'passes message and exception to retries exhausted block' do
|
it 'passes job and exception to retries exhausted block' do
|
||||||
raised_error = assert_raises RuntimeError do
|
raised_error = assert_raises RuntimeError do
|
||||||
handler.call(new_worker, job('retry_count' => 0, 'retry' => 1), 'default') do
|
handler.call(new_worker, job('retry_count' => 0, 'retry' => 1), 'default') do
|
||||||
raise 'kerblammo!'
|
raise 'kerblammo!'
|
||||||
|
@ -104,11 +104,11 @@ class TestRetryExhausted < Sidekiq::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
assert new_worker.exhausted_called?
|
assert new_worker.exhausted_called?
|
||||||
assert_equal raised_error.message, new_worker.exhausted_message['error_message']
|
assert_equal raised_error.message, new_worker.exhausted_job['error_message']
|
||||||
assert_equal raised_error, new_worker.exhausted_exception
|
assert_equal raised_error, new_worker.exhausted_exception
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'passes message to retries exhausted block' do
|
it 'passes job to retries exhausted block' do
|
||||||
raised_error = assert_raises RuntimeError do
|
raised_error = assert_raises RuntimeError do
|
||||||
handler.call(old_worker, job('retry_count' => 0, 'retry' => 1), 'default') do
|
handler.call(old_worker, job('retry_count' => 0, 'retry' => 1), 'default') do
|
||||||
raise 'kerblammo!'
|
raise 'kerblammo!'
|
||||||
|
@ -116,8 +116,34 @@ class TestRetryExhausted < Sidekiq::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
assert old_worker.exhausted_called?
|
assert old_worker.exhausted_called?
|
||||||
assert_equal raised_error.message, old_worker.exhausted_message['error_message']
|
assert_equal raised_error.message, old_worker.exhausted_job['error_message']
|
||||||
assert_equal nil, new_worker.exhausted_exception
|
assert_equal nil, new_worker.exhausted_exception
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'allows a global default handler' do
|
||||||
|
begin
|
||||||
|
class Foobar
|
||||||
|
include Sidekiq::Worker
|
||||||
|
end
|
||||||
|
|
||||||
|
exhausted_job = nil
|
||||||
|
exhausted_exception = nil
|
||||||
|
Sidekiq.default_retries_exhausted = lambda do |job, ex|
|
||||||
|
exhausted_job = job
|
||||||
|
exhausted_exception = ex
|
||||||
|
end
|
||||||
|
f = Foobar.new
|
||||||
|
raised_error = assert_raises RuntimeError do
|
||||||
|
handler.call(f, job('retry_count' => 0, 'retry' => 1), 'default') do
|
||||||
|
raise 'kerblammo!'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert exhausted_job
|
||||||
|
assert_equal raised_error, exhausted_exception
|
||||||
|
ensure
|
||||||
|
Sidekiq.default_retries_exhausted = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -96,4 +96,11 @@ class TestSidekiq < Sidekiq::Test
|
||||||
assert_equal counts[0] + 1, counts[1]
|
assert_equal counts[0] + 1, counts[1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'redis info' do
|
||||||
|
it 'calls the INFO command which returns at least redis_version' do
|
||||||
|
output = Sidekiq.redis_info
|
||||||
|
assert_includes output.keys, "redis_version"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -86,7 +86,7 @@ class TestInline < Sidekiq::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should relay parameters through json' do
|
it 'should relay parameters through json' do
|
||||||
assert Sidekiq::Client.enqueue(InlineWorkerWithTimeParam, Time.now)
|
assert Sidekiq::Client.enqueue(InlineWorkerWithTimeParam, Time.now.to_f)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,11 +6,7 @@ class TestUtil < Sidekiq::Test
|
||||||
include Sidekiq::Util
|
include Sidekiq::Util
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_hertz_donut
|
def test_nothing_atm
|
||||||
obj = Helpers.new
|
assert true
|
||||||
output = capture_logging(Logger::DEBUG) do
|
|
||||||
assert_equal false, obj.want_a_hertz_donut?
|
|
||||||
end
|
|
||||||
assert_includes output, "hz: 10"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,6 +33,7 @@ cs:
|
||||||
NextRetry: Další opakování
|
NextRetry: Další opakování
|
||||||
RetryCount: Počet opakování
|
RetryCount: Počet opakování
|
||||||
RetryNow: Opakovat teď
|
RetryNow: Opakovat teď
|
||||||
|
Kill: Zabít
|
||||||
LastRetry: Poslední opakování
|
LastRetry: Poslední opakování
|
||||||
OriginallyFailed: Původně se nezdařilo
|
OriginallyFailed: Původně se nezdařilo
|
||||||
AreYouSure: Jste si jisti?
|
AreYouSure: Jste si jisti?
|
||||||
|
@ -61,8 +62,17 @@ cs:
|
||||||
Failures: Selhání
|
Failures: Selhání
|
||||||
DeadJobs: Mrtvé úkoly
|
DeadJobs: Mrtvé úkoly
|
||||||
NoDeadJobsFound: Nebyly nalezeny žádné mrtvé úkoly
|
NoDeadJobsFound: Nebyly nalezeny žádné mrtvé úkoly
|
||||||
Dead: Mrtvý
|
Dead: Mrtvé
|
||||||
Processes: Procesy
|
Processes: Procesy
|
||||||
Thread: Vlákno
|
Thread: Vlákno
|
||||||
Threads: Vlákna
|
Threads: Vlákna
|
||||||
Jobs: Úkoly
|
Jobs: Úkoly
|
||||||
|
Paused: Pozastavené
|
||||||
|
Stop: Zastavit
|
||||||
|
Quiet: Ztišit
|
||||||
|
StopAll: Zastavit vše
|
||||||
|
QuietAll: Ztišit vše
|
||||||
|
PollingInterval: Interval obnovení
|
||||||
|
Plugins: Doplňky
|
||||||
|
NotYetEnqueued: Ještě nezařazeno
|
||||||
|
CreatedAt: Vytvořeno
|
||||||
|
|
|
@ -6,12 +6,12 @@ fr:
|
||||||
Namespace: Namespace
|
Namespace: Namespace
|
||||||
Realtime: Temps réel
|
Realtime: Temps réel
|
||||||
History: Historique
|
History: Historique
|
||||||
Busy: Occupées
|
Busy: En cours
|
||||||
Processed: Traitées
|
Processed: Traitées
|
||||||
Failed: Échouées
|
Failed: Échouées
|
||||||
Scheduled: Planifiée
|
Scheduled: Planifiées
|
||||||
Retries: Tentatives
|
Retries: Tentatives
|
||||||
Enqueued: En queue
|
Enqueued: En attente
|
||||||
Worker: Travailleur
|
Worker: Travailleur
|
||||||
LivePoll: Temps réel
|
LivePoll: Temps réel
|
||||||
StopPolling: Arrêt du temps réel
|
StopPolling: Arrêt du temps réel
|
||||||
|
@ -20,8 +20,8 @@ fr:
|
||||||
Job: Tâche
|
Job: Tâche
|
||||||
Arguments: Arguments
|
Arguments: Arguments
|
||||||
Extras: Extras
|
Extras: Extras
|
||||||
Started: Démarrées
|
Started: Démarrée
|
||||||
ShowAll: Montrer tout
|
ShowAll: Tout montrer
|
||||||
CurrentMessagesInQueue: Messages actuellement dans <span class='title'>%{queue}</span>
|
CurrentMessagesInQueue: Messages actuellement dans <span class='title'>%{queue}</span>
|
||||||
Delete: Supprimer
|
Delete: Supprimer
|
||||||
AddToQueue: Ajouter à la queue
|
AddToQueue: Ajouter à la queue
|
||||||
|
@ -35,7 +35,7 @@ fr:
|
||||||
RetryNow: Réessayer maintenant
|
RetryNow: Réessayer maintenant
|
||||||
Kill: Tuer
|
Kill: Tuer
|
||||||
LastRetry: Dernier essai
|
LastRetry: Dernier essai
|
||||||
OriginallyFailed: Échec originel
|
OriginallyFailed: Échec initial
|
||||||
AreYouSure: Êtes-vous certain ?
|
AreYouSure: Êtes-vous certain ?
|
||||||
DeleteAll: Tout supprimer
|
DeleteAll: Tout supprimer
|
||||||
RetryAll: Tout réessayer
|
RetryAll: Tout réessayer
|
||||||
|
@ -45,11 +45,11 @@ fr:
|
||||||
ErrorMessage: Message d’erreur
|
ErrorMessage: Message d’erreur
|
||||||
ErrorBacktrace: Backtrace d’erreur
|
ErrorBacktrace: Backtrace d’erreur
|
||||||
GoBack: ← Retour
|
GoBack: ← Retour
|
||||||
NoScheduledFound: Pas de tâches planifiées trouvées
|
NoScheduledFound: Aucune tâche planifiée n'a été trouvée
|
||||||
When: Quand
|
When: Quand
|
||||||
ScheduledJobs: Tâches planifiées
|
ScheduledJobs: Tâches planifiées
|
||||||
idle: en attente
|
idle: inactif
|
||||||
active: actives
|
active: actif
|
||||||
Version: Version
|
Version: Version
|
||||||
Connections: Connexions
|
Connections: Connexions
|
||||||
MemoryUsage: Mémoire utilisée
|
MemoryUsage: Mémoire utilisée
|
||||||
|
@ -62,8 +62,17 @@ fr:
|
||||||
Failures: Echecs
|
Failures: Echecs
|
||||||
DeadJobs: Tâches mortes
|
DeadJobs: Tâches mortes
|
||||||
NoDeadJobsFound: Aucune tâche morte n'a été trouvée
|
NoDeadJobsFound: Aucune tâche morte n'a été trouvée
|
||||||
Dead: Morte
|
Dead: Mortes
|
||||||
Processes: Processus
|
Processes: Processus
|
||||||
Thread: Thread
|
Thread: Thread
|
||||||
Threads: Threads
|
Threads: Threads
|
||||||
Jobs: Tâches
|
Jobs: Tâches
|
||||||
|
Paused: Mise en pause
|
||||||
|
Stop: Arrêter
|
||||||
|
Quiet: Clôturer
|
||||||
|
StopAll: Tout arrêter
|
||||||
|
QuietAll: Tout clôturer
|
||||||
|
PollingInterval: Interval de rafraîchissement
|
||||||
|
Plugins: Plugins
|
||||||
|
NotYetEnqueued: Pas encore en file d'attente
|
||||||
|
CreatedAt: Créée le
|
||||||
|
|
Loading…
Reference in a new issue