propono 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/propono.rb +16 -0
- data/lib/propono/services/queue_listener.rb +11 -0
- data/lib/propono/version.rb +1 -1
- data/propono.gemspec +1 -1
- data/test/propono_test.rb +6 -0
- data/test/services/queue_listener_test.rb +13 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 158f942077120ee93c8c02b1f44007ad1292eb3e
|
4
|
+
data.tar.gz: aa5ad40b0f52a720e0c6f291453ab827d53a297a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98a05da78d36f413b9f1ae7be5fb3fa667c81348cce0d46b97cf0de95ad286f3fbfcb4b1e3588a0fa7f765c2687552a466d2bd1bbd9ea38bc3ae3db15a13563b
|
7
|
+
data.tar.gz: 5e8f33d494c1cf232a51a0a4051fe0548e2a853df8c15ca707a6f270a1b7c27ca7a2256fc368ace22a2e97b29a3b006067f2033b39048ac6ea6175fd61baad7d
|
data/CHANGELOG.md
CHANGED
data/lib/propono.rb
CHANGED
@@ -107,6 +107,22 @@ module Propono
|
|
107
107
|
QueueListener.listen(topic, &message_processor)
|
108
108
|
end
|
109
109
|
|
110
|
+
# Listens on a queue and yields for each message
|
111
|
+
#
|
112
|
+
# Calling this will enter a queue-listening loop that
|
113
|
+
# yields the message_processor for each messages. The
|
114
|
+
# loop will end when all messages have been processed.
|
115
|
+
#
|
116
|
+
# This method will automatically create a subscription if
|
117
|
+
# one does not exist, so there is no need to call
|
118
|
+
# <tt>subscribe_by_queue</tt> in addition.
|
119
|
+
#
|
120
|
+
# @param [String] topic The topic to subscribe to.
|
121
|
+
# @param &message_processor The block to yield for each message.
|
122
|
+
def self.drain_queue(topic, &message_processor)
|
123
|
+
QueueListener.drain(topic, &message_processor)
|
124
|
+
end
|
125
|
+
|
110
126
|
# Listens for UDP messages and yields for each.
|
111
127
|
#
|
112
128
|
# Calling this will enter a queue-listening loop that
|
@@ -7,6 +7,10 @@ module Propono
|
|
7
7
|
new(topic_id, &message_processor).listen
|
8
8
|
end
|
9
9
|
|
10
|
+
def self.drain(topic_id, &message_processor)
|
11
|
+
new(topic_id, &message_processor).drain
|
12
|
+
end
|
13
|
+
|
10
14
|
def initialize(topic_id, &message_processor)
|
11
15
|
@topic_id = topic_id
|
12
16
|
@message_processor = message_processor
|
@@ -21,6 +25,13 @@ module Propono
|
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
28
|
+
def drain
|
29
|
+
raise ProponoError.new("topic_id is nil") unless @topic_id
|
30
|
+
while read_messages
|
31
|
+
# continue as long as there are messages in the queue
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
24
35
|
private
|
25
36
|
|
26
37
|
def read_messages
|
data/lib/propono/version.rb
CHANGED
data/propono.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "fog", "~> 1.15
|
21
|
+
spec.add_dependency "fog", "~> 1.15"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
spec.add_development_dependency "rake"
|
data/test/propono_test.rb
CHANGED
@@ -36,6 +36,12 @@ module Propono
|
|
36
36
|
Propono.listen_to_queue(topic)
|
37
37
|
end
|
38
38
|
|
39
|
+
def test_drain_queue_calls_queue_listener
|
40
|
+
topic = 'foobar'
|
41
|
+
QueueListener.expects(:drain).with(topic)
|
42
|
+
Propono.drain_queue(topic)
|
43
|
+
end
|
44
|
+
|
39
45
|
def test_listen_to_udp_calls_udp_listener
|
40
46
|
UdpListener.expects(:listen).with()
|
41
47
|
Propono.listen_to_udp()
|
@@ -41,6 +41,19 @@ module Propono
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
def test_drain_should_continue_if_queue_empty
|
45
|
+
@listener.expects(:read_messages).returns(nil)
|
46
|
+
@listener.drain
|
47
|
+
assert true
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_drain_raises_with_nil_topic
|
51
|
+
listener = QueueListener.new(nil) {}
|
52
|
+
assert_raises ProponoError do
|
53
|
+
listener.drain
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
44
57
|
def test_read_messages_should_subscribe
|
45
58
|
QueueSubscription.expects(create: mock(queue: mock(url: {})))
|
46
59
|
@listener.send(:read_messages)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: propono
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MalcyL
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.15
|
20
|
+
version: '1.15'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 1.15
|
27
|
+
version: '1.15'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: bundler
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
179
|
version: '0'
|
180
180
|
requirements: []
|
181
181
|
rubyforge_project:
|
182
|
-
rubygems_version: 2.1
|
182
|
+
rubygems_version: 2.2.1
|
183
183
|
signing_key:
|
184
184
|
specification_version: 4
|
185
185
|
summary: General purpose pub/sub library built on top of AWS SNS and SQS
|