sidekiq 5.0.4 → 5.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5eafdd7cf02082ddca6e556df6c2ef191c20380
4
- data.tar.gz: eb520ecf4dd12b4c95da1d1b3765958aaf0f2e19
3
+ metadata.gz: 96202101069aaee71e462e2f3b91f5d4c58e952f
4
+ data.tar.gz: ad75e0b5dc019bb8d1058b124535190f00b06f60
5
5
  SHA512:
6
- metadata.gz: 83ea17045bfd9f870b98af2292ff9490b752cd47bcdfdd8cfc73a5d4779e4ce56635b5ff7f4d76b6a791ff9e60b06281fc955e5cc1d3201f78a0d3ea995237bb
7
- data.tar.gz: 784e604fac0fe0ffd914c87a973717de466b2b5a68bb710cddedd702ba39d4c2d6489a3be98ad868c8139f99d7cca231de593377bc268ca232c7c2dca585c3c8
6
+ metadata.gz: 4de121e1a00611b97f5c8838c5beb1d5a4fa5e6fb37e7cd7b2ac2074239d8a48d1d9526d4a8c0a94fcfcebe7ee3507209735569c78309f18d29363fbab24b992
7
+ data.tar.gz: 239a247dd69bab58148229f64d7b8ff12a658bb696c08c9f00b9ee9170c5d40ea052891eef5d89742633282d99095b4eb6004df298aa2f06b5f114fbbcfb10de
data/Changes.md CHANGED
@@ -2,10 +2,18 @@
2
2
 
3
3
  [Sidekiq Changes](https://github.com/mperham/sidekiq/blob/master/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md)
4
4
 
5
+ HEAD
6
+ -----------
7
+
8
+ - Update gemspec to allow newer versions of the Redis gem [#3617]
9
+ - Refactor Worker.set so it can be memoized [#3602]
10
+ - Fix display of Redis URL in web footer, broken in 5.0.3 [#3560]
11
+
5
12
  5.0.4
6
13
  -----------
7
14
 
8
15
  - Fix "slow startup" performance regression from 5.0.2. [#3525]
16
+ - Allow users to disable ID generation since some redis providers disable the CLIENT command. [#3521]
9
17
 
10
18
  5.0.3
11
19
  -----------
@@ -4,6 +4,11 @@
4
4
 
5
5
  Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
6
6
 
7
+ 1.6.1
8
+ -------------
9
+
10
+ - Fix crash in rate limiter middleware when used with custom exceptions [#3604]
11
+
7
12
  1.6.0
8
13
  -------------
9
14
 
data/Gemfile CHANGED
@@ -8,6 +8,9 @@ gem 'minitest'
8
8
  #gem 'minitest-utils'
9
9
  gem 'toxiproxy'
10
10
 
11
+ # For Redis 4.0 support. Unreleased 9cb81bf.
12
+ gem 'redis-namespace', git: 'https://github.com/resque/redis-namespace'
13
+
11
14
  platforms :rbx do
12
15
  gem 'rubysl', '~> 2.0' # if using anything in the ruby standard library
13
16
  gem 'psych' # if using yaml
@@ -4,7 +4,14 @@
4
4
 
5
5
  Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
6
6
 
7
- HEAD
7
+ 3.5.3
8
+ ---------
9
+
10
+ - Restore error check for super\_fetch's job ack [#3601]
11
+ - Trim error messages saved in Batch's failure hash, preventing huge
12
+ messages from bloating Redis. [#3570]
13
+
14
+ 3.5.2
8
15
  ---------
9
16
 
10
17
  - Fix `Status#completed?` when run against a Batch that had succeeded
@@ -335,7 +335,7 @@ module Sidekiq
335
335
 
336
336
  def display_args
337
337
  # Unwrap known wrappers so they show up in a human-friendly manner in the Web UI
338
- @args ||= case klass
338
+ @display_args ||= case klass
339
339
  when /\ASidekiq::Extensions::Delayed/
340
340
  safe_load(args[0], args) do |_, _, arg|
341
341
  arg
@@ -458,14 +458,7 @@ module Sidekiq
458
458
  # Place job in the dead set
459
459
  def kill
460
460
  remove_job do |message|
461
- now = Time.now.to_f
462
- Sidekiq.redis do |conn|
463
- conn.multi do
464
- conn.zadd('dead', now, message)
465
- conn.zremrangebyscore('dead', '-inf', now - DeadSet.timeout)
466
- conn.zremrangebyrank('dead', 0, - DeadSet.max_jobs)
467
- end
468
- end
461
+ DeadSet.new.kill(message)
469
462
  end
470
463
  end
471
464
 
@@ -663,6 +656,17 @@ module Sidekiq
663
656
  super 'dead'
664
657
  end
665
658
 
659
+ def kill(message)
660
+ now = Time.now.to_f
661
+ Sidekiq.redis do |conn|
662
+ conn.multi do
663
+ conn.zadd(name, now.to_s, message)
664
+ conn.zremrangebyscore(name, '-inf', now - self.class.timeout)
665
+ conn.zremrangebyrank(name, 0, - self.class.max_jobs)
666
+ end
667
+ end
668
+ end
669
+
666
670
  def retry_all
667
671
  while size > 0
668
672
  each(&:retry)
@@ -51,7 +51,10 @@ module Sidekiq
51
51
  # at - timestamp to schedule the job (optional), must be Numeric (e.g. Time.now.to_f)
52
52
  # retry - whether to retry this job if it fails, default true or an integer number of retries
53
53
  # backtrace - whether to save any error backtrace, default false
54
- #
54
+ #
55
+ # If class is set to the class name, the jobs' options will be based on Sidekiq's default
56
+ # worker options. Otherwise, they will be based on the job class's options.
57
+ #
55
58
  # Any options valid for a worker class's sidekiq_options are also available here.
56
59
  #
57
60
  # All options must be strings, not symbols. NB: because we are serializing to JSON, all
@@ -24,7 +24,7 @@ module Sidekiq
24
24
 
25
25
  module PsychAutoload
26
26
  def resolve_class(klass_name)
27
- return klass_name unless klass_name
27
+ return nil if !klass_name || klass_name.empty?
28
28
  # constantize
29
29
  names = klass_name.split('::')
30
30
  names.shift if names.empty? || names.first.empty?
@@ -184,14 +184,7 @@ module Sidekiq
184
184
  def send_to_morgue(msg)
185
185
  Sidekiq.logger.info { "Adding dead #{msg['class']} job #{msg['jid']}" }
186
186
  payload = Sidekiq.dump_json(msg)
187
- now = Time.now.to_f
188
- Sidekiq.redis do |conn|
189
- conn.multi do
190
- conn.zadd('dead', now, payload)
191
- conn.zremrangebyscore('dead', '-inf', now - DeadSet.timeout)
192
- conn.zremrangebyrank('dead', 0, -DeadSet.max_jobs)
193
- end
194
- end
187
+ DeadSet.new.kill(payload)
195
188
  end
196
189
 
197
190
  def retry_attempts_from(msg_retry, default)
@@ -126,7 +126,7 @@ module Sidekiq
126
126
  pristine = cloned(job_hash)
127
127
 
128
128
  Sidekiq::Logging.with_job_hash_context(job_hash) do
129
- @retrier.global(job_hash, queue) do
129
+ @retrier.global(pristine, queue) do
130
130
  @logging.call(job_hash, queue) do
131
131
  stats(pristine, queue) do
132
132
  # Rails 5 requires a Reloader to wrap code execution. In order to
@@ -137,7 +137,7 @@ module Sidekiq
137
137
  klass = constantize(job_hash['class'.freeze])
138
138
  worker = klass.new
139
139
  worker.jid = job_hash['jid'.freeze]
140
- @retrier.local(worker, job_hash, queue) do
140
+ @retrier.local(worker, pristine, queue) do
141
141
  yield worker
142
142
  end
143
143
  end
@@ -159,7 +159,7 @@ module Sidekiq
159
159
  job_hash = Sidekiq.load_json(jobstr)
160
160
  rescue => ex
161
161
  handle_exception(ex, { :context => "Invalid JSON for job", :jobstr => jobstr })
162
- send_to_morgue(jobstr)
162
+ DeadSet.new.kill(jobstr)
163
163
  ack = true
164
164
  raise
165
165
  end
@@ -184,17 +184,6 @@ module Sidekiq
184
184
  end
185
185
  end
186
186
 
187
- def send_to_morgue(msg)
188
- now = Time.now.to_f
189
- Sidekiq.redis do |conn|
190
- conn.multi do
191
- conn.zadd('dead', now, msg)
192
- conn.zremrangebyscore('dead', '-inf', now - DeadSet.timeout)
193
- conn.zremrangebyrank('dead', 0, -DeadSet.max_jobs)
194
- end
195
- end
196
- end
197
-
198
187
  def execute_job(worker, cloned_args)
199
188
  worker.perform(*cloned_args)
200
189
  end
@@ -21,7 +21,7 @@ module Sidekiq
21
21
 
22
22
  def safe_thread(name, &block)
23
23
  Thread.new do
24
- Thread.current['sidekiq_label'] = name
24
+ Thread.current['sidekiq_label'.freeze] = name
25
25
  watchdog(name, &block)
26
26
  end
27
27
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Sidekiq
3
- VERSION = "5.0.4"
3
+ VERSION = "5.0.5"
4
4
  end
@@ -148,7 +148,8 @@ module Sidekiq
148
148
  end
149
149
 
150
150
  def redis_connection
151
- Sidekiq.redis { |conn| conn.client.id }
151
+ attrs = Sidekiq.redis { |conn| conn.connection }
152
+ "redis://#{attrs[:location]}/#{attrs[:db]}"
152
153
  end
153
154
 
154
155
  def namespace
@@ -41,12 +41,13 @@ module Sidekiq
41
41
  # SomeWorker.set(queue: 'foo').perform_async(....)
42
42
  #
43
43
  class Setter
44
- def initialize(opts)
44
+ def initialize(klass, opts)
45
+ @klass = klass
45
46
  @opts = opts
46
47
  end
47
48
 
48
49
  def perform_async(*args)
49
- @opts['class'.freeze].client_push(@opts.merge!('args'.freeze => args))
50
+ @klass.client_push(@opts.merge('args'.freeze => args, 'class'.freeze => @klass))
50
51
  end
51
52
 
52
53
  # +interval+ must be a timestamp, numeric or something that acts
@@ -56,10 +57,10 @@ module Sidekiq
56
57
  now = Time.now.to_f
57
58
  ts = (int < 1_000_000_000 ? now + int : int)
58
59
 
59
- @opts.merge! 'args'.freeze => args, 'at'.freeze => ts
60
+ payload = @opts.merge('class'.freeze => @klass, 'args'.freeze => args, 'at'.freeze => ts)
60
61
  # Optimization to enqueue something now that is scheduled to go out now or in the past
61
- @opts.delete('at'.freeze) if ts <= now
62
- @opts['class'.freeze].client_push(@opts)
62
+ payload.delete('at'.freeze) if ts <= now
63
+ @klass.client_push(payload)
63
64
  end
64
65
  alias_method :perform_at, :perform_in
65
66
  end
@@ -79,7 +80,7 @@ module Sidekiq
79
80
  end
80
81
 
81
82
  def set(options)
82
- Setter.new(options.merge!('class'.freeze => self))
83
+ Setter.new(self, options)
83
84
  end
84
85
 
85
86
  def perform_async(*args)
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.version = Sidekiq::VERSION
18
18
  gem.required_ruby_version = ">= 2.2.2"
19
19
 
20
- gem.add_dependency 'redis', '~> 3.3', '>= 3.3.3'
20
+ gem.add_dependency 'redis', '>= 3.3.4', '< 5'
21
21
  gem.add_dependency 'connection_pool', '~> 2.2', '>= 2.2.0'
22
22
  gem.add_dependency 'concurrent-ruby', '~> 1.0'
23
23
  gem.add_dependency 'rack-protection', '>= 1.5.0'
metadata CHANGED
@@ -1,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.4
4
+ version: 5.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-03 00:00:00.000000000 Z
11
+ date: 2017-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '3.3'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 3.3.3
19
+ version: 3.3.4
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '3.3'
30
27
  - - ">="
31
28
  - !ruby/object:Gem::Version
32
- version: 3.3.3
29
+ version: 3.3.4
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: connection_pool
35
35
  requirement: !ruby/object:Gem::Requirement