sidekiq 7.1.0 → 7.1.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e35d1e6eac7b96128e63d16ffaa1e1b435edd2d1af2e9ba9eb41e7b548ecafdd
4
- data.tar.gz: 24717c4bdef48d83ee1467f97a216f023937b2a69a5db726614b78ea054a9699
3
+ metadata.gz: 587dc2a304b24daba86943907fe6b0285ecd302119e900e68403fcf0dedff163
4
+ data.tar.gz: 713489d61003baf22b07879e959048bede62a5b661cf37a6c43540cd3cd59eac
5
5
  SHA512:
6
- metadata.gz: 70d4e5e58853a86ee8761c6c766daac03333fd7752c4102db8caca0e1631d7d37377acb3fe2e616497d02e067fbee2577ccdf0b5497cb95ae0ce5414232bac25
7
- data.tar.gz: 628c9516bd22b09e2b431f917f3218200c137dd36534e9742c41b916e3994b609aecf119e9e0c8caf359ad8b30b2a95974d507e6e99a6e330f5651a4af4142ab
6
+ metadata.gz: 026b2dd393d8e9774f1afa6fe4df9cfca70520e84a0d566dde668e535809492476004f205668d16bbe2d5f0111fb4d51a4ddddd60bfd6a1c90d906bcb50b5c92
7
+ data.tar.gz: 5b6769ef293543a4d7003e870c5ed5b1d9b7d44a941c4fc446afd16531fc1eaae2f684359fb7c093eb1761c517ff31c106f247c17a8e2808bb629adf47061a62
data/Changes.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  [Sidekiq Changes](https://github.com/sidekiq/sidekiq/blob/main/Changes.md) | [Sidekiq Pro Changes](https://github.com/sidekiq/sidekiq/blob/main/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/sidekiq/sidekiq/blob/main/Ent-Changes.md)
4
4
 
5
+ 7.1.2
6
+ ----------
7
+
8
+ - Mark Web UI assets as private so CDNs won't cache them [#5936]
9
+ - Fix stackoverflow when using Oj and the JSON log formatter [#5920]
10
+ - Remove spurious `enqueued_at` from scheduled ActiveJobs [#5937]
11
+
12
+ 7.1.1
13
+ ----------
14
+
15
+ - Support multiple CurrentAttributes [#5904]
16
+ - Speed up latency fetch with large queues on Redis <7 [#5910]
17
+ - Allow a larger default client pool [#5886]
18
+ - Ensure Sidekiq.options[:environment] == RAILS_ENV [#5932]
19
+
5
20
  7.1.0
6
21
  ----------
7
22
 
@@ -101,6 +116,11 @@ end
101
116
  - Job Execution metrics!!!
102
117
  - See `docs/7.0-Upgrade.md` for release notes
103
118
 
119
+ 6.5.9
120
+ ----------
121
+
122
+ - Ensure Sidekiq.options[:environment] == RAILS_ENV [#5932]
123
+
104
124
  6.5.8
105
125
  ----------
106
126
 
data/lib/sidekiq/api.rb CHANGED
@@ -92,11 +92,11 @@ module Sidekiq
92
92
  pipeline.zcard("retry")
93
93
  pipeline.zcard("dead")
94
94
  pipeline.scard("processes")
95
- pipeline.lrange("queue:default", -1, -1)
95
+ pipeline.lindex("queue:default", -1)
96
96
  end
97
97
  }
98
98
 
99
- default_queue_latency = if (entry = pipe1_res[6].first)
99
+ default_queue_latency = if (entry = pipe1_res[6])
100
100
  job = begin
101
101
  Sidekiq.load_json(entry)
102
102
  rescue
@@ -264,8 +264,8 @@ module Sidekiq
264
264
  # @return [Float] in seconds
265
265
  def latency
266
266
  entry = Sidekiq.redis { |conn|
267
- conn.lrange(@rname, -1, -1)
268
- }.first
267
+ conn.lindex(@rname, -1)
268
+ }
269
269
  return 0 unless entry
270
270
  job = Sidekiq.load_json(entry)
271
271
  now = Time.now.to_f
data/lib/sidekiq/cli.rb CHANGED
@@ -230,6 +230,7 @@ module Sidekiq # :nodoc:
230
230
  # Both Sinatra 2.0+ and Sidekiq support this term.
231
231
  # RAILS_ENV and RACK_ENV are there for legacy support.
232
232
  @environment = cli_env || ENV["APP_ENV"] || ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
233
+ config[:environment] = @environment
233
234
  end
234
235
 
235
236
  def symbolize_keys_deep!(hash)
@@ -246,6 +246,8 @@ module Sidekiq
246
246
  if payloads.first.key?("at")
247
247
  conn.zadd("schedule", payloads.flat_map { |hash|
248
248
  at = hash.delete("at").to_s
249
+ # ActiveJob sets this but the job has not been enqueued yet
250
+ hash.delete("enqueued_at")
249
251
  [at, Sidekiq.dump_json(hash)]
250
252
  })
251
253
  else
@@ -56,6 +56,10 @@ module Sidekiq
56
56
  def_delegators :@options, :[], :[]=, :fetch, :key?, :has_key?, :merge!
57
57
  attr_reader :capsules
58
58
 
59
+ def to_json(*)
60
+ Sidekiq.dump_json(@options)
61
+ end
62
+
59
63
  # LEGACY: edits the default capsule
60
64
  # config.concurrency = 5
61
65
  def concurrency=(val)
@@ -127,7 +131,7 @@ module Sidekiq
127
131
  private def local_redis_pool
128
132
  # this is our internal client/housekeeping pool. each capsule has its
129
133
  # own pool for executing threads.
130
- @redis ||= new_redis_pool(5, "internal")
134
+ @redis ||= new_redis_pool(10, "internal")
131
135
  end
132
136
 
133
137
  def new_redis_pool(size, name = "unset")
@@ -263,7 +267,7 @@ module Sidekiq
263
267
  ctx[:_config] = self
264
268
  @options[:error_handlers].each do |handler|
265
269
  handler.call(ex, ctx)
266
- rescue => e
270
+ rescue Exception => e
267
271
  l = logger
268
272
  l.error "!!! ERROR HANDLER THREW AN ERROR !!!"
269
273
  l.error e
@@ -7,26 +7,32 @@ module Sidekiq
7
7
  # This can be useful for multi-tenancy, i18n locale, timezone, any implicit
8
8
  # per-request attribute. See +ActiveSupport::CurrentAttributes+.
9
9
  #
10
+ # For multiple current attributes, pass an array of current attributes.
11
+ #
10
12
  # @example
11
13
  #
12
14
  # # in your initializer
13
15
  # require "sidekiq/middleware/current_attributes"
14
16
  # Sidekiq::CurrentAttributes.persist("Myapp::Current")
17
+ # # or multiple current attributes
18
+ # Sidekiq::CurrentAttributes.persist(["Myapp::Current", "Myapp::OtherCurrent"])
15
19
  #
16
20
  module CurrentAttributes
17
21
  class Save
18
22
  include Sidekiq::ClientMiddleware
19
23
 
20
- def initialize(cattr)
21
- @strklass = cattr
24
+ def initialize(cattrs)
25
+ @cattrs = cattrs
22
26
  end
23
27
 
24
28
  def call(_, job, _, _)
25
- if !job.has_key?("cattr")
26
- attrs = @strklass.constantize.attributes
27
- # Retries can push the job N times, we don't
28
- # want retries to reset cattr. #5692, #5090
29
- job["cattr"] = attrs if attrs.any?
29
+ @cattrs.each do |(key, strklass)|
30
+ if !job.has_key?(key)
31
+ attrs = strklass.constantize.attributes
32
+ # Retries can push the job N times, we don't
33
+ # want retries to reset cattr. #5692, #5090
34
+ job[key] = attrs if attrs.any?
35
+ end
30
36
  end
31
37
  yield
32
38
  end
@@ -35,22 +41,55 @@ module Sidekiq
35
41
  class Load
36
42
  include Sidekiq::ServerMiddleware
37
43
 
38
- def initialize(cattr)
39
- @strklass = cattr
44
+ def initialize(cattrs)
45
+ @cattrs = cattrs
40
46
  end
41
47
 
42
48
  def call(_, job, _, &block)
43
- if job.has_key?("cattr")
44
- @strklass.constantize.set(job["cattr"], &block)
45
- else
46
- yield
49
+ cattrs_to_reset = []
50
+
51
+ @cattrs.each do |(key, strklass)|
52
+ if job.has_key?(key)
53
+ constklass = strklass.constantize
54
+ cattrs_to_reset << constklass
55
+
56
+ job[key].each do |(attribute, value)|
57
+ constklass.public_send("#{attribute}=", value)
58
+ end
59
+ end
47
60
  end
61
+
62
+ yield
63
+ ensure
64
+ cattrs_to_reset.each(&:reset)
48
65
  end
49
66
  end
50
67
 
51
- def self.persist(klass, config = Sidekiq.default_configuration)
52
- config.client_middleware.add Save, klass.to_s
53
- config.server_middleware.add Load, klass.to_s
68
+ class << self
69
+ def persist(klass_or_array, config = Sidekiq.default_configuration)
70
+ cattrs = build_cattrs_hash(klass_or_array)
71
+
72
+ config.client_middleware.add Save, cattrs
73
+ config.server_middleware.add Load, cattrs
74
+ end
75
+
76
+ private
77
+
78
+ def build_cattrs_hash(klass_or_array)
79
+ if klass_or_array.is_a?(Array)
80
+ {}.tap do |hash|
81
+ klass_or_array.each_with_index do |klass, index|
82
+ hash[key_at(index)] = klass.to_s
83
+ end
84
+ end
85
+ else
86
+ {key_at(0) => klass_or_array.to_s}
87
+ end
88
+ end
89
+
90
+ def key_at(index)
91
+ (index == 0) ? "cattr" : "cattr_#{index}"
92
+ end
54
93
  end
55
94
  end
56
95
  end
data/lib/sidekiq/rails.rb CHANGED
@@ -20,6 +20,10 @@ module Sidekiq
20
20
  def inspect
21
21
  "#<Sidekiq::Rails::Reloader @app=#{@app.class.name}>"
22
22
  end
23
+
24
+ def to_json(*)
25
+ Sidekiq.dump_json(inspect)
26
+ end
23
27
  end
24
28
 
25
29
  # By including the Options module, we allow AJs to directly control sidekiq features
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sidekiq
4
- VERSION = "7.1.0"
4
+ VERSION = "7.1.2"
5
5
  MAJOR = 7
6
6
  end
data/lib/sidekiq/web.rb CHANGED
@@ -137,7 +137,7 @@ module Sidekiq
137
137
  m = middlewares
138
138
 
139
139
  rules = []
140
- rules = [[:all, {"cache-control" => "public, max-age=86400"}]] unless ENV["SIDEKIQ_WEB_TESTING"]
140
+ rules = [[:all, {"Cache-Control" => "private, max-age=86400"}]] unless ENV["SIDEKIQ_WEB_TESTING"]
141
141
 
142
142
  ::Rack::Builder.new do
143
143
  use Rack::Static, urls: ["/stylesheets", "/images", "/javascripts"],
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.0
4
+ version: 7.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-01 00:00:00.000000000 Z
11
+ date: 2023-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client