sidekiq-pauzer 4.1.0 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +9 -0
- data/lib/sidekiq/pauzer/queues.rb +43 -20
- data/lib/sidekiq/pauzer/version.rb +1 -1
- data/lib/sidekiq/pauzer.rb +1 -3
- data/web/views/queues.erb +2 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7ba4ea9d9b061ee7d506874e2f6dd7e3128d912f194df3f7eea66e134ee5342
|
4
|
+
data.tar.gz: e7c7a9140a6fb5e450b13ab2f97740908036d4cca4d28a1dbb40cea1210ce7b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1abbf6aa4603205e520b197f93b08f6ad485a285c33dd64bb1b7eb01b8e54f80f0622a816d2fabf43b369c16abdf73beda3b220446ea023f9fe197bd11eeb7f0
|
7
|
+
data.tar.gz: f70b7cff1ef0955a932c0df368425213524bcf286d6ec4bc9803cf2486c246b835d2c6ae5c3c1f118b7c7adcc09e929a124295218183e45daf266eebca779535
|
data/README.adoc
CHANGED
@@ -30,6 +30,15 @@ Sidekiq::Pauzer.configure do |config|
|
|
30
30
|
end
|
31
31
|
----
|
32
32
|
|
33
|
+
When running in forked environment (e.g., Puma web server), you also need to
|
34
|
+
call `Sidekiq::Pauzer.startup` on fork:
|
35
|
+
|
36
|
+
[source, ruby]
|
37
|
+
----
|
38
|
+
# file: config/puma.rb
|
39
|
+
on_worker_boot { Sidekiq::Pauzer.startup }
|
40
|
+
----
|
41
|
+
|
33
42
|
=== API
|
34
43
|
|
35
44
|
This gem enhances Sidekiq's Queue API with:
|
@@ -1,41 +1,55 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "forwardable"
|
3
4
|
require "concurrent"
|
4
5
|
|
5
6
|
module Sidekiq
|
6
7
|
module Pauzer
|
7
8
|
# @api internal
|
8
9
|
class Queues
|
10
|
+
extend Forwardable
|
9
11
|
include Enumerable
|
10
12
|
|
11
|
-
|
13
|
+
# @!attribute [r] redis_key
|
14
|
+
# @see (Config#redis_key)
|
15
|
+
def_delegators :@config, :redis_key
|
16
|
+
|
17
|
+
# @!attribute [r] refresh_rate
|
18
|
+
# @see (Config#refresh_rate)
|
19
|
+
def_delegators :@config, :refresh_rate
|
12
20
|
|
13
21
|
# @param config [Config]
|
14
22
|
def initialize(config)
|
15
|
-
@
|
16
|
-
@names
|
17
|
-
@
|
18
|
-
@refresher
|
23
|
+
@config = config
|
24
|
+
@names = [].freeze
|
25
|
+
@names_mutex = Mutex.new
|
26
|
+
@refresher = nil
|
27
|
+
@refresher_mutex = Mutex.new
|
19
28
|
end
|
20
29
|
|
21
30
|
def each(&block)
|
22
31
|
return to_enum __method__ unless block
|
23
32
|
|
24
|
-
|
33
|
+
start_refresher unless refresher_running?
|
34
|
+
@names_mutex.synchronize { @names.dup }.each(&block)
|
25
35
|
|
26
36
|
self
|
27
37
|
end
|
28
38
|
|
29
39
|
# @param name [#to_s]
|
40
|
+
# @return [Queues] self
|
30
41
|
def pause!(name)
|
31
|
-
|
42
|
+
redis_call("SADD", redis_key, name.to_s)
|
32
43
|
refresh
|
44
|
+
self
|
33
45
|
end
|
34
46
|
|
35
47
|
# @param name [#to_s]
|
48
|
+
# @return [Queues] self
|
36
49
|
def unpause!(name)
|
37
|
-
|
50
|
+
redis_call("SREM", redis_key, name.to_s)
|
38
51
|
refresh
|
52
|
+
self
|
39
53
|
end
|
40
54
|
|
41
55
|
# @param name [#to_s]
|
@@ -45,35 +59,44 @@ module Sidekiq
|
|
45
59
|
end
|
46
60
|
|
47
61
|
def start_refresher
|
48
|
-
@
|
62
|
+
@refresher_mutex.synchronize do
|
63
|
+
@refresher&.shutdown
|
64
|
+
@refresher = Concurrent::TimerTask.execute(execution_interval: refresh_rate, run_now: true) { refresh }
|
65
|
+
end
|
49
66
|
|
50
67
|
self
|
51
68
|
end
|
52
69
|
|
53
70
|
def stop_refresher
|
54
|
-
@
|
71
|
+
@refresher_mutex.synchronize do
|
72
|
+
@refresher&.shutdown
|
73
|
+
@refresher = nil
|
74
|
+
end
|
55
75
|
|
56
76
|
self
|
57
77
|
end
|
58
78
|
|
59
79
|
def refresher_running?
|
60
|
-
@
|
80
|
+
@refresher_mutex.synchronize do
|
81
|
+
@refresher&.running? || false
|
82
|
+
end
|
61
83
|
end
|
62
84
|
|
63
85
|
private
|
64
86
|
|
65
|
-
|
66
|
-
Refresher.new(execution_interval: refresh_rate, run_now: true) do
|
67
|
-
refresh
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
87
|
+
# @return [nil]
|
71
88
|
def refresh
|
72
|
-
names =
|
89
|
+
names = redis_call("SMEMBERS", redis_key).to_a
|
90
|
+
|
91
|
+
@names_mutex.synchronize do
|
92
|
+
@names = names.each(&:freeze).freeze
|
93
|
+
end
|
73
94
|
|
74
|
-
|
95
|
+
nil
|
96
|
+
end
|
75
97
|
|
76
|
-
|
98
|
+
def redis_call(...)
|
99
|
+
Sidekiq.redis { |conn| conn.call(...) }
|
77
100
|
end
|
78
101
|
end
|
79
102
|
end
|
data/lib/sidekiq/pauzer.rb
CHANGED
@@ -108,7 +108,7 @@ module Sidekiq
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def startup
|
111
|
-
MUTEX.synchronize {
|
111
|
+
MUTEX.synchronize { reinit_queues.start_refresher }
|
112
112
|
|
113
113
|
self
|
114
114
|
end
|
@@ -122,10 +122,8 @@ module Sidekiq
|
|
122
122
|
private
|
123
123
|
|
124
124
|
def reinit_queues
|
125
|
-
start_refresher = @queues.refresher_running?
|
126
125
|
@queues.stop_refresher
|
127
126
|
@queues = Queues.new(@config)
|
128
|
-
@queues.start_refresher if start_refresher
|
129
127
|
end
|
130
128
|
end
|
131
129
|
end
|
data/web/views/queues.erb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-pauzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1
|
4
|
+
version: 4.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Zapparov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -58,14 +58,14 @@ files:
|
|
58
58
|
- lib/sidekiq/pauzer/version.rb
|
59
59
|
- lib/sidekiq/pauzer/web.rb
|
60
60
|
- web/views/queues.erb
|
61
|
-
homepage: https://
|
61
|
+
homepage: https://github.com/ixti/sidekiq-pauzer
|
62
62
|
licenses:
|
63
63
|
- MIT
|
64
64
|
metadata:
|
65
|
-
homepage_uri: https://
|
66
|
-
source_code_uri: https://
|
67
|
-
bug_tracker_uri: https://
|
68
|
-
changelog_uri: https://
|
65
|
+
homepage_uri: https://github.com/ixti/sidekiq-pauzer
|
66
|
+
source_code_uri: https://github.com/ixti/sidekiq-pauzer/tree/v4.2.1
|
67
|
+
bug_tracker_uri: https://github.com/ixti/sidekiq-pauzer/issues
|
68
|
+
changelog_uri: https://github.com/ixti/sidekiq-pauzer/blob/v4.2.1/CHANGES.md
|
69
69
|
rubygems_mfa_required: 'true'
|
70
70
|
post_install_message:
|
71
71
|
rdoc_options: []
|