mercury_amqp 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mercury/test_utils.rb +30 -0
- data/lib/mercury/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 046bcdd150e6875d732e623389624a2d26abb08c
|
4
|
+
data.tar.gz: 1d5bc9696f0bd8ee418ba99c3326c4c6cfb5fa2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98d86ee54503071de7bec6037b6539f6931e15fef44428ad85ba6ed32ed7e38ab9a735973c3e039b6268b4dec39caaf13cb764b408c0b41988c045eb690d1cb9
|
7
|
+
data.tar.gz: 9bbe848304af07e201adbeadbe0452826694a0b89e862d4958461069c284584c00b15408a12682b068edf7386b39e56708f9c56b38611e961b4f09e6b5ed1747
|
data/lib/mercury/test_utils.rb
CHANGED
@@ -4,6 +4,8 @@ require 'mercury/monadic'
|
|
4
4
|
|
5
5
|
class Mercury
|
6
6
|
module TestUtils
|
7
|
+
include Cps::Methods
|
8
|
+
|
7
9
|
def em
|
8
10
|
EM.run do
|
9
11
|
EM.add_timer(in_debug_mode? ? 999999 : 3) { raise 'EM spec timed out' }
|
@@ -52,6 +54,34 @@ class Mercury
|
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
57
|
+
def read_all_messages(worker: , source:, tag:, seconds_to_wait: 0.1)
|
58
|
+
msgs = []
|
59
|
+
last_received_time = Time.now
|
60
|
+
msg_handler = ->(msg) do
|
61
|
+
msgs << msg
|
62
|
+
msg.ack
|
63
|
+
last_received_time = Time.now
|
64
|
+
end
|
65
|
+
EM.run do
|
66
|
+
Cps.seql do
|
67
|
+
let(:m) { Mercury::Monadic.open }
|
68
|
+
and_then { m.start_worker(worker, source, msg_handler, tag_filter: tag) }
|
69
|
+
and_then { wait_until { (Time.now - last_received_time).to_f > seconds_to_wait } }
|
70
|
+
and_then { m.close }
|
71
|
+
and_lift { EM.stop }
|
72
|
+
end.run
|
73
|
+
end
|
74
|
+
msgs
|
75
|
+
end
|
76
|
+
|
77
|
+
def cps_benchmark(label, &block)
|
78
|
+
seql do
|
79
|
+
let(:time) { lift { Time.now } }
|
80
|
+
and_then { block.call }
|
81
|
+
and_lift { puts "#{label} : #{(Time.now - time) * 1000} ms" }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
55
85
|
def amq_filter(xs)
|
56
86
|
xs.reject{|x| x.start_with?('amq.')}
|
57
87
|
end
|
data/lib/mercury/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Winton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|