sneakers-laces 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/sneakers/laces/queue_manager.rb +32 -2
- data/lib/sneakers/laces/version.rb +1 -1
- data/sneakers-laces.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf540a0f1e0cf7fadad770d57c25a94fd1059032ea14e67e2c641e42b385dc71
|
4
|
+
data.tar.gz: e51c42076f98ed9743541e11db61676584d7cd6015fd8304799c8087338abbce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efb3320e566ae8bcce8fa4acd6a43f053e05c13830e51a071e43bd4bdf8e8f62ece62ced2870f46cf3085cc110365f1f41934ccafdc604899744ef73ca347612
|
7
|
+
data.tar.gz: cab414d73d13fea6228f33e18df58f79f2ec1c6cc522a77639379fd498fd27ac21c3d4a63517fab0f45358fa9f6df0877fa57b44bfccea90e36c96b74898e991
|
data/README.md
CHANGED
@@ -66,6 +66,15 @@ Sneakers.publish('user 2', to_queue: 'user_2')
|
|
66
66
|
|
67
67
|
# This will delete queue and send message to reload workers
|
68
68
|
queue_manager.delete_queue name: 'user_2', worker_tag: 'api_requester'
|
69
|
+
|
70
|
+
# This will pause queue by creating a extra binding and send message to reload workers
|
71
|
+
queue_manager.pause_queue name: 'user_1', worker_tag: 'api_requester'
|
72
|
+
|
73
|
+
# You still can publish to a "paused" queues
|
74
|
+
Sneakers.publish('user 1', to_queue: 'user_1')
|
75
|
+
|
76
|
+
# Make queue "processable" again
|
77
|
+
queue_manager.unpause_queue name: 'user_1', worker_tag: 'api_requester'
|
69
78
|
```
|
70
79
|
|
71
80
|
## Contributing
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'base64'
|
4
|
+
|
3
5
|
module Sneakers
|
4
6
|
module Laces
|
5
7
|
class QueueManager
|
@@ -15,6 +17,18 @@ module Sneakers
|
|
15
17
|
reload_worker(worker_tag) if reload
|
16
18
|
end
|
17
19
|
|
20
|
+
def pause_queue(name:, worker_tag:, reload: true)
|
21
|
+
api_client.bind_queue(vhost, name, exchange, pause_routing_key(name))
|
22
|
+
|
23
|
+
reload_worker(worker_tag) if reload
|
24
|
+
end
|
25
|
+
|
26
|
+
def unpause_queue(name:, worker_tag:, reload: true)
|
27
|
+
api_client.delete_queue_binding(vhost, name, exchange, pause_routing_key(name))
|
28
|
+
|
29
|
+
reload_worker(worker_tag) if reload
|
30
|
+
end
|
31
|
+
|
18
32
|
def grouped_queues
|
19
33
|
filtered_queues.group_by { |q| q.arguments[WORKER_TAG_ARGUMENT] }
|
20
34
|
end
|
@@ -38,14 +52,30 @@ module Sneakers
|
|
38
52
|
api_client.queue_info vhost, name
|
39
53
|
end
|
40
54
|
|
41
|
-
|
55
|
+
def list_bindings
|
56
|
+
api_client.list_bindings(vhost)
|
57
|
+
rescue Faraday::ResourceNotFound
|
58
|
+
[]
|
59
|
+
end
|
60
|
+
|
61
|
+
def pause_routing_key(name)
|
62
|
+
[
|
63
|
+
'pause',
|
64
|
+
Base64.strict_encode64(name)
|
65
|
+
].join('.')
|
66
|
+
end
|
42
67
|
|
43
68
|
def reload_worker(worker_tag)
|
44
69
|
Sneakers::Laces.reload(worker_tag: worker_tag)
|
45
70
|
end
|
46
71
|
|
47
72
|
def filtered_queues
|
48
|
-
|
73
|
+
bindings = list_bindings
|
74
|
+
|
75
|
+
list_queues.select do |queue|
|
76
|
+
queue.arguments[WORKER_TAG_ARGUMENT].present? &&
|
77
|
+
bindings.none? { |b| b.destination == queue.name && b.routing_key == pause_routing_key(queue.name) }
|
78
|
+
end
|
49
79
|
end
|
50
80
|
|
51
81
|
def params_with_worker_tag(worker_tag, params = {})
|
data/sneakers-laces.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ['rustam@sharshenov.com']
|
12
12
|
|
13
13
|
spec.summary = 'Configure your Sneakers worker on-the-fly'
|
14
|
-
spec.description = 'Subscribe your Sneakers workers to
|
14
|
+
spec.description = 'Subscribe your Sneakers workers to dynamically added/removed queues without process restart'
|
15
15
|
spec.homepage = 'https://github.com/sharshenov/sneakers-laces'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sneakers-laces
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Sharshenov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -94,8 +94,8 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
description: Subscribe your Sneakers workers to
|
98
|
-
restart
|
97
|
+
description: Subscribe your Sneakers workers to dynamically added/removed queues without
|
98
|
+
process restart
|
99
99
|
email:
|
100
100
|
- rustam@sharshenov.com
|
101
101
|
executables: []
|