sidekiq-alive-next 2.2.1 → 3.0.0

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
  SHA256:
3
- metadata.gz: 2262ac5bd03e54f13b80361452b90a306b61e0058f1496bf4d73d5f8a41593f9
4
- data.tar.gz: 32a79905ca77cdf401828c8ea0ba9e5067c97b487c52d54ef8912716f005ab74
3
+ metadata.gz: b348a1daf1eb508fcd8c171d454451f40552c1a30696edaaecb956cdc270f601
4
+ data.tar.gz: 30f55c866378f828c52ea5255bc667d04fa23fc3f7f7a33a332848ba72be972b
5
5
  SHA512:
6
- metadata.gz: edc3042d9d3655ee8caec0f0c4207f78f102a2aae7a9c719f3bab8d9e6f4786c7550b7aaedf9b400d147af87e7ae9a5dfdd6db89998531a6377180ff0d2becc8
7
- data.tar.gz: 2df4f3673588024031eafcb03095233cc4efa66263fc9fb98e7d9a76191ebb4648b468a105594c0ec148031748f817469918fa68195aa73e6b6a0f83961ba5b2
6
+ metadata.gz: fafd8efa2b7cb77093d8d9c79bf793612534eb12c2c342e519a96adf851f8bdf2bae155887b54409cc8af40e99fdc17141b783365630956e3f41e4c571873a18
7
+ data.tar.gz: a29b9cf9035f589d23859faf270523c125c6f80c7ef77d60cd77d4c497113698eaee74df0c81071f6527a05d870d1a260a3ddb2421f4befa1299b6ac02ed906e
data/README.md CHANGED
@@ -277,7 +277,7 @@ Here is an example [rails app](https://github.com/arturictus/sidekiq_alive_examp
277
277
 
278
278
  ## Contributing
279
279
 
280
- Bug reports and pull requests are welcome on GitHub at https://github.com/arturictus/sidekiq_alive. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
280
+ Bug reports and pull requests are welcome on GitHub at https://github.com/andrcuns/sidekiq-alive. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
281
281
 
282
282
  ## License
283
283
 
@@ -14,7 +14,7 @@ module SidekiqAlive
14
14
  Sidekiq.configure_server do |sq_config|
15
15
  sq_config.on(:startup) do
16
16
  SidekiqAlive::Worker.sidekiq_options(queue: current_queue)
17
- (sq_config.respond_to?(:[]) ? sq_config[:queues] : sq_config.options[:queues]).unshift(current_queue)
17
+ sq_config.queues.unshift(current_queue)
18
18
 
19
19
  logger.info(startup_info)
20
20
 
@@ -53,29 +53,18 @@ module SidekiqAlive
53
53
  # Delete any pending jobs for this instance
54
54
  logger.info(shutdown_info)
55
55
  purge_pending_jobs
56
- redis.del(current_instance_register_key)
56
+ redis.call("DEL", current_instance_register_key)
57
57
  end
58
58
 
59
59
  def registered_instances
60
- deep_scan("#{config.registered_instance_key}::*")
61
- end
62
-
63
- def deep_scan(keyword, keys = [], cursor = 0)
64
- loop do
65
- cursor, found_keys = SidekiqAlive.redis.scan(cursor, match: keyword, count: 1000)
66
- keys += found_keys
67
- break if cursor.to_i.zero?
68
- end
69
- keys
60
+ redis.scan("MATCH", "#{config.registered_instance_key}::*").map { |key| key }
70
61
  end
71
62
 
72
63
  def purge_pending_jobs
73
- # TODO: Sidekiq 6 allows better way to find scheduled jobs
74
- # https://github.com/mperham/sidekiq/wiki/API#scan
75
- scheduled_set = Sidekiq::ScheduledSet.new
76
- jobs = scheduled_set.select { |job| job.klass == "SidekiqAlive::Worker" && job.queue == current_queue }
64
+ jobs = Sidekiq::ScheduledSet.new.scan('"class":"SidekiqAlive::Worker"')
77
65
  logger.info("[SidekiqAlive] Purging #{jobs.count} pending for #{hostname}")
78
66
  jobs.each(&:delete)
67
+
79
68
  logger.info("[SidekiqAlive] Removing queue #{current_queue}")
80
69
  Sidekiq::Queue.new(current_queue).clear
81
70
  end
@@ -85,9 +74,7 @@ module SidekiqAlive
85
74
  end
86
75
 
87
76
  def store_alive_key
88
- redis.set(current_lifeness_key,
89
- Time.now.to_i,
90
- ex: config.time_to_live.to_i)
77
+ redis.call("SET", current_lifeness_key, Time.now.to_i, ex: config.time_to_live.to_i)
91
78
  end
92
79
 
93
80
  def redis
@@ -130,6 +117,8 @@ module SidekiqAlive
130
117
  port: config.port,
131
118
  ttl: config.time_to_live,
132
119
  queue: current_queue,
120
+ liveness_key: current_lifeness_key,
121
+ register_key: current_instance_register_key,
133
122
  }
134
123
 
135
124
  "Starting sidekiq-alive: #{info}"
@@ -140,9 +129,9 @@ module SidekiqAlive
140
129
  end
141
130
 
142
131
  def register_instance(instance_name)
143
- redis.set(instance_name, Time.now.to_i, ex: config.registration_ttl.to_i)
132
+ redis.call("SET", instance_name, Time.now.to_i, ex: config.registration_ttl.to_i)
144
133
  end
145
- end
134
+ end
146
135
  end
147
136
 
148
137
  require "sidekiq_alive/worker"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SidekiqAlive
4
- VERSION = "2.2.1"
4
+ VERSION = "3.0.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-alive-next
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrejs Cunskis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-10-15 00:00:00.000000000 Z
12
+ date: 2022-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -25,34 +25,20 @@ dependencies:
25
25
  - - ">"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.16'
28
- - !ruby/object:Gem::Dependency
29
- name: mock_redis
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: '0'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: rack-test
44
30
  requirement: !ruby/object:Gem::Requirement
45
31
  requirements:
46
- - - ">="
32
+ - - "~>"
47
33
  - !ruby/object:Gem::Version
48
- version: '0'
34
+ version: 2.0.2
49
35
  type: :development
50
36
  prerelease: false
51
37
  version_requirements: !ruby/object:Gem::Requirement
52
38
  requirements:
53
- - - ">="
39
+ - - "~>"
54
40
  - !ruby/object:Gem::Version
55
- version: '0'
41
+ version: 2.0.2
56
42
  - !ruby/object:Gem::Dependency
57
43
  name: rake
58
44
  requirement: !ruby/object:Gem::Requirement
@@ -124,25 +110,45 @@ dependencies:
124
110
  - !ruby/object:Gem::Version
125
111
  version: 0.47.2
126
112
  - !ruby/object:Gem::Dependency
127
- name: sidekiq
113
+ name: rack
128
114
  requirement: !ruby/object:Gem::Requirement
129
115
  requirements:
130
116
  - - ">="
131
117
  - !ruby/object:Gem::Version
132
- version: '5'
118
+ version: 2.2.4
133
119
  - - "<"
134
120
  - !ruby/object:Gem::Version
135
- version: '7'
121
+ version: '3'
136
122
  type: :runtime
137
123
  prerelease: false
138
124
  version_requirements: !ruby/object:Gem::Requirement
139
125
  requirements:
140
126
  - - ">="
141
127
  - !ruby/object:Gem::Version
142
- version: '5'
128
+ version: 2.2.4
143
129
  - - "<"
130
+ - !ruby/object:Gem::Version
131
+ version: '3'
132
+ - !ruby/object:Gem::Dependency
133
+ name: sidekiq
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
144
137
  - !ruby/object:Gem::Version
145
138
  version: '7'
139
+ - - "<"
140
+ - !ruby/object:Gem::Version
141
+ version: '8'
142
+ type: :runtime
143
+ prerelease: false
144
+ version_requirements: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '7'
149
+ - - "<"
150
+ - !ruby/object:Gem::Version
151
+ version: '8'
146
152
  - !ruby/object:Gem::Dependency
147
153
  name: webrick
148
154
  requirement: !ruby/object:Gem::Requirement
@@ -193,7 +199,7 @@ metadata:
193
199
  homepage_uri: https://github.com/andrcuns/sidekiq-alive
194
200
  source_code_uri: https://github.com/andrcuns/sidekiq-alive
195
201
  changelog_uri: https://github.com/andrcuns/sidekiq-alive/releases
196
- documentation_uri: https://github.com/andrcuns/sidekiq-alive/blob/v2.2.1/README.md
202
+ documentation_uri: https://github.com/andrcuns/sidekiq-alive/blob/v3.0.0/README.md
197
203
  bug_tracker_uri: https://github.com/andrcuns/sidekiq-alive/issues
198
204
  post_install_message:
199
205
  rdoc_options: []