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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecf7917c63df98ddac8e56561aab982fc16592d9
4
- data.tar.gz: e59c232c4f97ac0f44fab2579cb3887b25f717da
3
+ metadata.gz: 046bcdd150e6875d732e623389624a2d26abb08c
4
+ data.tar.gz: 1d5bc9696f0bd8ee418ba99c3326c4c6cfb5fa2d
5
5
  SHA512:
6
- metadata.gz: 2d4830869b364b0b31da8875701d927a3eb03c54274bcaeadd778a5f2f93ca597e6a70751d0ddd89a013d1df2e1728f544674236288e288f67425e2028af17a2
7
- data.tar.gz: 84d5e36eff96f6430d62148e3007569c50fd3d7a489f630d86f31bbee7711463a0512e6684698b32d2bb3f527b60a643184dae9b1979f697872f3b648d16e95f
6
+ metadata.gz: 98d86ee54503071de7bec6037b6539f6931e15fef44428ad85ba6ed32ed7e38ab9a735973c3e039b6268b4dec39caaf13cb764b408c0b41988c045eb690d1cb9
7
+ data.tar.gz: 9bbe848304af07e201adbeadbe0452826694a0b89e862d4958461069c284584c00b15408a12682b068edf7386b39e56708f9c56b38611e961b4f09e6b5ed1747
@@ -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
@@ -1,3 +1,3 @@
1
1
  class Mercury
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
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.3
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-23 00:00:00.000000000 Z
11
+ date: 2015-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler