sidekiq-throttled 0.9.0 → 0.10.0.alpha

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: cc7a98ab5bb314051a1771f82401d9eb0f33e976434a61ec2851f4b3cb653e15
4
- data.tar.gz: a04d5ca0da17d9c49f5fea46763d622b81e20cd3f43d1431902b901670bfe45c
3
+ metadata.gz: 83591901b017e382b25575720fab1bbcc45ac9e81acec417da1a10cbfa333613
4
+ data.tar.gz: 1a135a2b18d51b644f7713cdd1d2bcad6ffe34b87ca93b11aa1336e2e1b91a8b
5
5
  SHA512:
6
- metadata.gz: 9b25afcecde886729c0e5519145bf3d796ba1cd6a77b2904cfb1203327b93b14f0a55768980ee83b6b7c7f8cb699a774c6a0842cf5d7e9fbddf22461b955ed01
7
- data.tar.gz: 0bb94625ae6f48229eaa8199b8a20af455910c6bb8b34c983af014e159f6d737bb2c210eba57fb53e58c7e729fa74d28413868805c63e53535c9ad5df9c83dcd
6
+ metadata.gz: 594b29b269f4b8c2351adf7f835cad04d974794ef596fdcd5492202c4e4f6af5d1a06b7ec67baf15a6d393aa2a60093cc7a536f87c8260f3681b25a817d94990
7
+ data.tar.gz: d4e9d76b8627c86ee7e399e563d7c9ce8bdbabc40444349a88ce88ea3bec136974505feb9b49d905bf47fc9aaf233270e9637ebca027d533e589ca93cc6cb2f5
data/CHANGES.md CHANGED
@@ -1,4 +1,4 @@
1
- ## 0.9.9 (2018-09-11)
1
+ ## 0.9.0 (2018-09-11)
2
2
 
3
3
  * Add support of Sidekiq 5.2.x
4
4
  ([@ixti])
@@ -39,6 +39,7 @@ module Sidekiq
39
39
  def initialize
40
40
  @paused_queues = Set.new
41
41
  @communicator = Communicator.instance
42
+ @mutex = Mutex.new
42
43
  end
43
44
 
44
45
  # Configures Sidekiq server to keep actual list of paused queues.
@@ -48,18 +49,13 @@ module Sidekiq
48
49
  def setup!
49
50
  Patches::Queue.apply!
50
51
 
51
- Sidekiq.configure_server do
52
- @communicator.receive PAUSE_MESSAGE do |queue|
53
- @paused_queues << QueueName.expand(queue)
54
- end
52
+ Sidekiq.configure_server do |config|
53
+ config.on(:startup) { start_watcher }
54
+ config.on(:quiet) { stop_watcher }
55
55
 
56
- @communicator.receive RESUME_MESSAGE do |queue|
57
- @paused_queues.delete QueueName.expand(queue)
58
- end
59
-
60
- @communicator.ready do
61
- @paused_queues.replace(paused_queues.map { |q| QueueName.expand q })
62
- end
56
+ @communicator.receive(PAUSE_MESSAGE, &method(:add))
57
+ @communicator.receive(RESUME_MESSAGE, &method(:delete))
58
+ @communicator.ready(&method(:sync!))
63
59
  end
64
60
  end
65
61
 
@@ -112,6 +108,41 @@ module Sidekiq
112
108
  @communicator.transmit(conn, RESUME_MESSAGE, queue)
113
109
  end
114
110
  end
111
+
112
+ private
113
+
114
+ def add(queue)
115
+ @mutex.synchronize do
116
+ @paused_queues << QueueName.expand(queue)
117
+ end
118
+ end
119
+
120
+ def delete(queue)
121
+ @mutex.synchronize do
122
+ @paused_queues.delete QueueName.expand(queue)
123
+ end
124
+ end
125
+
126
+ def sync!
127
+ @mutex.synchronize do
128
+ @paused_queues.replace(paused_queues.map { |q| QueueName.expand q })
129
+ end
130
+ end
131
+
132
+ def start_watcher
133
+ @mutex.synchronize do
134
+ @watcher ||= Concurrent::TimerTask.execute({
135
+ :run_now => true,
136
+ :execution_interval => 60
137
+ }) { sync! }
138
+ end
139
+ end
140
+
141
+ def stop_watcher
142
+ @mutex.synchronize do
143
+ defined?(@watcher) && @watcher&.shutdown
144
+ end
145
+ end
115
146
  end
116
147
  end
117
148
  end
@@ -3,6 +3,6 @@
3
3
  module Sidekiq
4
4
  module Throttled
5
5
  # Gem version
6
- VERSION = "0.9.0"
6
+ VERSION = "0.10.0.alpha"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-throttled
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey V Zapparov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-11 00:00:00.000000000 Z
11
+ date: 2018-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -134,9 +134,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
134
  version: '0'
135
135
  required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - ">="
137
+ - - ">"
138
138
  - !ruby/object:Gem::Version
139
- version: '0'
139
+ version: 1.3.1
140
140
  requirements: []
141
141
  rubyforge_project:
142
142
  rubygems_version: 2.7.6