sidekiq-alive-next 2.2.1 → 3.1.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: a18bb6defb7f2d0d3eb1e1b01ce12b683c5c634be2e43b74600b787cdf4ae0e9
4
+ data.tar.gz: d0bb5d30eeee984dee67e75228d5d6ca3df91301eea805414dee6665dd058859
5
5
  SHA512:
6
- metadata.gz: edc3042d9d3655ee8caec0f0c4207f78f102a2aae7a9c719f3bab8d9e6f4786c7550b7aaedf9b400d147af87e7ae9a5dfdd6db89998531a6377180ff0d2becc8
7
- data.tar.gz: 2df4f3673588024031eafcb03095233cc4efa66263fc9fb98e7d9a76191ebb4648b468a105594c0ec148031748f817469918fa68195aa73e6b6a0f83961ba5b2
6
+ metadata.gz: 15cbeff2addefafddb0416fc194d5943d190bf03d1482b57a7b09771c72edaf015cee7ea55b23a055a775526b5a55b854c5251f27835839339e1d31a996f0523
7
+ data.tar.gz: 2c6e9f7aae03381045cc0b641b8caaff01ac6d8b51932f902e1578a6923e2ec62c4b1c4c6e9d6c54183a64fd56e0d2f766d26c99fd832f8c60b3fb5394f6babb
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # SidekiqAlive
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/sidekiq-alive-next.svg)](https://rubygems.org/gems/sidekiq-alive-next)
4
+ [![Total Downloads](https://img.shields.io/gem/dt/sidekiq-alive-next?color=blue)](https://rubygems.org/gems/https://rubygems.org/gems/sidekiq-alive-next)
5
+ ![Workflow status](https://github.com/allure-framework/allure-ruby/workflows/Test/badge.svg)
6
+ [![Known Vulnerabilities](https://snyk.io/test/github/andrcuns/sidekiq-alive/badge.svg)](https://snyk.io/test/github/andrcuns/sidekiq-alive)
7
+
3
8
  **This is the fork of 'arturictus/sidekiq_alive' with a few minor fixes and tweaks, all credit goes to author of original repo**
4
9
 
5
10
  SidekiqAlive offers a solution to add liveness probe for a Sidekiq instance deployed in Kubernetes.
@@ -277,7 +282,7 @@ Here is an example [rails app](https://github.com/arturictus/sidekiq_alive_examp
277
282
 
278
283
  ## Contributing
279
284
 
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.
285
+ 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
286
 
282
287
  ## License
283
288
 
@@ -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,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rack"
4
+ require "rackup"
4
5
 
5
6
  module SidekiqAlive
6
7
  class Server
7
8
  class << self
8
9
  def run!
9
- handler = Rack::Handler.get(server)
10
+ handler = Rackup::Handler.get(server)
10
11
 
11
12
  Signal.trap("TERM") { handler.shutdown }
12
13
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SidekiqAlive
4
- VERSION = "2.2.1"
4
+ VERSION = "3.1.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.1.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-11-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -26,33 +26,33 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.16'
28
28
  - !ruby/object:Gem::Dependency
29
- name: mock_redis
29
+ name: debug
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: '1.6'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
41
+ version: '1.6'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rack-test
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
48
+ version: 2.0.2
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '0'
55
+ version: 2.0.2
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rake
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -124,25 +124,59 @@ dependencies:
124
124
  - !ruby/object:Gem::Version
125
125
  version: 0.47.2
126
126
  - !ruby/object:Gem::Dependency
127
- name: sidekiq
127
+ name: rack
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
- version: '5'
132
+ version: '3'
133
133
  - - "<"
134
134
  - !ruby/object:Gem::Version
135
- version: '7'
135
+ version: '4'
136
+ type: :runtime
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '3'
143
+ - - "<"
144
+ - !ruby/object:Gem::Version
145
+ version: '4'
146
+ - !ruby/object:Gem::Dependency
147
+ name: rackup
148
+ requirement: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.2.2
136
153
  type: :runtime
137
154
  prerelease: false
138
155
  version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.2.2
160
+ - !ruby/object:Gem::Dependency
161
+ name: sidekiq
162
+ requirement: !ruby/object:Gem::Requirement
139
163
  requirements:
140
164
  - - ">="
141
165
  - !ruby/object:Gem::Version
142
- version: '5'
166
+ version: '7'
143
167
  - - "<"
168
+ - !ruby/object:Gem::Version
169
+ version: '8'
170
+ type: :runtime
171
+ prerelease: false
172
+ version_requirements: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
144
175
  - !ruby/object:Gem::Version
145
176
  version: '7'
177
+ - - "<"
178
+ - !ruby/object:Gem::Version
179
+ version: '8'
146
180
  - !ruby/object:Gem::Dependency
147
181
  name: webrick
148
182
  requirement: !ruby/object:Gem::Requirement
@@ -193,7 +227,7 @@ metadata:
193
227
  homepage_uri: https://github.com/andrcuns/sidekiq-alive
194
228
  source_code_uri: https://github.com/andrcuns/sidekiq-alive
195
229
  changelog_uri: https://github.com/andrcuns/sidekiq-alive/releases
196
- documentation_uri: https://github.com/andrcuns/sidekiq-alive/blob/v2.2.1/README.md
230
+ documentation_uri: https://github.com/andrcuns/sidekiq-alive/blob/v3.1.0/README.md
197
231
  bug_tracker_uri: https://github.com/andrcuns/sidekiq-alive/issues
198
232
  post_install_message:
199
233
  rdoc_options: []