mercury_amqp 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/lib/mercury/cps/methods.rb +1 -1
- data/lib/mercury/cps/seq_with_let.rb +2 -4
- data/lib/mercury/mercury.rb +27 -11
- data/lib/mercury/monadic.rb +1 -0
- data/mercury_amqp.gemspec +1 -2
- data/spec/lib/mercury/monadic_spec.rb +15 -1
- metadata +4 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16118238db6731dd009db956a965bdc70f73c6c5
|
4
|
+
data.tar.gz: fcf5cdbe1e5fcf2a45835dc8fce12933acf65216
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23d4b1f2bfee00745bac70bba0f362e022a5360c7c6bd1d6b7e76a756d7b6aeb45ee74181e2f45f5628d2602fb66c42d9e5ebe682fc58648034eaf200722db7a
|
7
|
+
data.tar.gz: c48a33ed99cb871992de68403a43dac7fee3f1ad8ced8a6513f7608c1f8f9c574af3f2e75c907f467f3d091c397d5597ac11cb385697e55646ac13347b857873
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.1
|
data/lib/mercury/cps/methods.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
require 'binding_of_caller'
|
2
|
-
|
3
1
|
class Mercury
|
4
2
|
class Cps
|
5
3
|
# Syntactic sugar for and_then chains.
|
6
|
-
def self.seql(
|
4
|
+
def self.seql(&block)
|
7
5
|
# EXPERIMENTAL
|
8
6
|
# The trick here is to execute the block in a context where
|
9
7
|
# 1. we can simulate local let-bound variables, and
|
@@ -17,7 +15,7 @@ class Mercury
|
|
17
15
|
#
|
18
16
|
# Note: parent instance variables are not available inside the block.
|
19
17
|
# Note: keyword arguments are not proxied to methods called in the parent binding
|
20
|
-
context = SeqWithLet.new(binding
|
18
|
+
context = SeqWithLet.new(block.binding)
|
21
19
|
context.instance_exec(&block)
|
22
20
|
context.__chain
|
23
21
|
end
|
data/lib/mercury/mercury.rb
CHANGED
@@ -114,14 +114,29 @@ class Mercury
|
|
114
114
|
guard_public(k)
|
115
115
|
with_source(source_name) do |exchange|
|
116
116
|
with_work_queue(worker_group, exchange, tag_filter) do |queue|
|
117
|
-
queue
|
118
|
-
handler.call(make_received_message(payload, metadata, work_queue_name: worker_group))
|
119
|
-
end
|
117
|
+
subscribe_worker(queue, handler)
|
120
118
|
k.call
|
121
119
|
end
|
122
120
|
end
|
123
121
|
end
|
124
122
|
|
123
|
+
# Production code should not call this.
|
124
|
+
# Only test/tool code should call this, and only if you're sure
|
125
|
+
# the worker queue already exists and is bound to the source
|
126
|
+
def start_queue_worker(worker_group, handler, &k)
|
127
|
+
guard_public(k)
|
128
|
+
@channel.queue(worker_group, work_queue_opts) do |queue|
|
129
|
+
subscribe_worker(queue, handler)
|
130
|
+
k.call
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
private def subscribe_worker(queue, handler)
|
135
|
+
queue.subscribe(ack: true) do |metadata, payload|
|
136
|
+
handler.call(make_received_message(payload, metadata, work_queue_name: queue.name))
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
125
140
|
def delete_source(source_name, &k)
|
126
141
|
guard_public(k)
|
127
142
|
with_source(source_name) do |exchange|
|
@@ -202,11 +217,11 @@ class Mercury
|
|
202
217
|
|
203
218
|
def dispatch_publisher_confirm(basic_ack)
|
204
219
|
confirmed_tags =
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
220
|
+
if basic_ack.multiple
|
221
|
+
@confirm_handlers.keys.select { |tag| tag <= basic_ack.delivery_tag }.sort # sort just to be deterministic
|
222
|
+
else
|
223
|
+
[basic_ack.delivery_tag]
|
224
|
+
end
|
210
225
|
confirmed_tags.each do |tag|
|
211
226
|
@confirm_handlers.delete(tag).call
|
212
227
|
end
|
@@ -310,9 +325,10 @@ class Mercury
|
|
310
325
|
|
311
326
|
def bind_queue(exchange, queue_name, tag_filter, opts, &k)
|
312
327
|
tag_filter ||= '#'
|
313
|
-
|
314
|
-
|
315
|
-
|
328
|
+
@channel.queue(queue_name, opts) do |queue|
|
329
|
+
queue.bind(exchange, routing_key: tag_filter) do
|
330
|
+
k.call(queue)
|
331
|
+
end
|
316
332
|
end
|
317
333
|
end
|
318
334
|
|
data/lib/mercury/monadic.rb
CHANGED
data/mercury_amqp.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'mercury_amqp'
|
7
|
-
spec.version = '0.
|
7
|
+
spec.version = '0.10.0'
|
8
8
|
spec.authors = ['Peter Winton']
|
9
9
|
spec.email = ['wintonpc@gmail.com']
|
10
10
|
spec.summary = 'AMQP-backed messaging layer'
|
@@ -28,6 +28,5 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_runtime_dependency 'oj', '~> 3.0'
|
29
29
|
spec.add_runtime_dependency 'amqp', '~> 1.5'
|
30
30
|
spec.add_runtime_dependency 'bunny', '~> 2.1'
|
31
|
-
spec.add_runtime_dependency 'binding_of_caller', '~> 0.7'
|
32
31
|
spec.add_runtime_dependency 'activesupport', '> 4.0', '< 6.0'
|
33
32
|
end
|
@@ -76,7 +76,7 @@ describe Mercury::Monadic do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
seql do
|
79
|
-
and_then { m.start_worker(
|
79
|
+
and_then { m.start_worker(queue1, source1, handle_msg) }
|
80
80
|
and_then { m.publish(source1, {'id' => 1, 'sleep_seconds' => 0.1}) }
|
81
81
|
and_then { m.publish(source1, {'id' => 2, 'sleep_seconds' => 0.1}) }
|
82
82
|
and_then { wait_until { events.size == 4 } }
|
@@ -87,6 +87,20 @@ describe Mercury::Monadic do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
it 'subscribes to a preexisting queue' do
|
91
|
+
test_with_mercury do |m|
|
92
|
+
msgs = []
|
93
|
+
seql do
|
94
|
+
let(:other_m) { Mercury::Monadic.open }
|
95
|
+
and_then { other_m.start_worker(queue1, source1, :nack.to_proc) }
|
96
|
+
and_then { other_m.close }
|
97
|
+
and_then { m.start_queue_worker(queue1, msgs.method(:push)) }
|
98
|
+
and_then { m.publish(source1, {'id' => 1}) }
|
99
|
+
and_then { wait_until { msgs.size == 1 } }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
90
104
|
itt 'sends and receives tagged messages' do
|
91
105
|
test_with_mercury do |m|
|
92
106
|
msgs = []
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mercury_amqp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Winton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -150,20 +150,6 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '2.1'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: binding_of_caller
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0.7'
|
160
|
-
type: :runtime
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0.7'
|
167
153
|
- !ruby/object:Gem::Dependency
|
168
154
|
name: activesupport
|
169
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,6 +179,7 @@ extra_rdoc_files: []
|
|
193
179
|
files:
|
194
180
|
- ".gitignore"
|
195
181
|
- ".rspec"
|
182
|
+
- ".ruby-version"
|
196
183
|
- CHANGES.md
|
197
184
|
- Gemfile
|
198
185
|
- README.md
|
@@ -250,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
237
|
version: '0'
|
251
238
|
requirements: []
|
252
239
|
rubyforge_project:
|
253
|
-
rubygems_version: 2.6.
|
240
|
+
rubygems_version: 2.6.12
|
254
241
|
signing_key:
|
255
242
|
specification_version: 4
|
256
243
|
summary: AMQP-backed messaging layer
|