propono 1.2.0 → 1.3.0
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/services/publisher.rb +22 -15
- data/lib/propono/version.rb +1 -1
- data/test/integration/slow_queue_test.rb +2 -2
- data/test/integration/tcp_to_sqs_test.rb +1 -1
- data/test/services/publisher_test.rb +12 -0
- data/test/services/queue_listener_test.rb +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cbff5dcb118c99e3f7ff39f3cfc172e478edb5e
|
4
|
+
data.tar.gz: 619b6da2339dd1a0c9feea52b4851e0735f6a826
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf7e492a492a3a31dd40fede408e1b084f996aff7b057f1747617a10f8d217028d2dca4541d381dd0da70612e89ca2b91b4d3a91696036e057a3504940760b47
|
7
|
+
data.tar.gz: f9fec93fc0c85902123a9b6d5c608ef711a89853e01502fd70d3c563797889707b14687522bd302abe5eeb039951d1a43a1bf94add6286955c6675533796dacb
|
data/CHANGELOG.md
CHANGED
@@ -11,7 +11,7 @@ module Propono
|
|
11
11
|
new(topic_id, message, options).publish
|
12
12
|
end
|
13
13
|
|
14
|
-
attr_reader :topic_id, :message, :protocol, :id
|
14
|
+
attr_reader :topic_id, :message, :protocol, :id, :async
|
15
15
|
|
16
16
|
def initialize(topic_id, message, options = {})
|
17
17
|
raise PublisherError.new("Topic is nil") if topic_id.nil?
|
@@ -24,6 +24,7 @@ module Propono
|
|
24
24
|
@protocol = options.fetch(:protocol, :sns).to_sym
|
25
25
|
@id = SecureRandom.hex(3)
|
26
26
|
@id = "#{options[:id]}-#{@id}" if options[:id]
|
27
|
+
@async = options.fetch(:async, true)
|
27
28
|
end
|
28
29
|
|
29
30
|
def publish
|
@@ -34,20 +35,26 @@ module Propono
|
|
34
35
|
private
|
35
36
|
|
36
37
|
def publish_via_sns
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
38
|
+
async ? publish_via_sns_asyncronously : publish_via_sns_syncronously
|
39
|
+
end
|
40
|
+
|
41
|
+
def publish_via_sns_asyncronously
|
42
|
+
Thread.new { publish_via_sns_syncronously }
|
43
|
+
end
|
44
|
+
|
45
|
+
def publish_via_sns_syncronously
|
46
|
+
begin
|
47
|
+
topic = TopicCreator.find_or_create(topic_id)
|
48
|
+
rescue => e
|
49
|
+
Propono.config.logger.error "Propono [#{id}]: Failed to create topic #{topic_id}: #{e}"
|
50
|
+
raise
|
51
|
+
end
|
52
|
+
|
53
|
+
begin
|
54
|
+
sns.publish(topic.arn, body.to_json)
|
55
|
+
rescue => e
|
56
|
+
Propono.config.logger.error "Propono [#{id}]: Failed to send via sns: #{e}"
|
57
|
+
raise
|
51
58
|
end
|
52
59
|
end
|
53
60
|
|
data/lib/propono/version.rb
CHANGED
@@ -36,8 +36,8 @@ module Propono
|
|
36
36
|
|
37
37
|
sleep(1) # Make sure the listener has started
|
38
38
|
|
39
|
-
Propono.publish(slow_topic, slow_text)
|
40
|
-
Propono.publish(topic, text)
|
39
|
+
Propono.publish(slow_topic, slow_text, async: false)
|
40
|
+
Propono.publish(topic, text, async: false)
|
41
41
|
flunks << "Test Timeout" unless wait_for_thread(thread)
|
42
42
|
flunk(flunks.join("\n")) unless flunks.empty?
|
43
43
|
ensure
|
@@ -223,5 +223,17 @@ module Propono
|
|
223
223
|
end
|
224
224
|
end
|
225
225
|
|
226
|
+
def test_publish_can_be_called_syncronously
|
227
|
+
publisher = Publisher.new("topic_id", "message", async: false)
|
228
|
+
publisher.expects(:publish_via_sns_syncronously).once
|
229
|
+
publisher.expects(:publish_via_sns_asyncronously).never
|
230
|
+
publisher.send(:publish_via_sns)
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_publish_is_normally_called_asyncronously
|
234
|
+
publisher = Publisher.new("topic_id", "message")
|
235
|
+
publisher.expects(:publish_via_sns_asyncronously)
|
236
|
+
publisher.send(:publish_via_sns)
|
237
|
+
end
|
226
238
|
end
|
227
239
|
end
|
@@ -25,7 +25,7 @@ module Propono
|
|
25
25
|
|
26
26
|
@listener = QueueListener.new(@topic_id) {}
|
27
27
|
@listener.stubs(sqs: @sqs)
|
28
|
-
|
28
|
+
|
29
29
|
Propono.config.max_retries = 0
|
30
30
|
end
|
31
31
|
|
@@ -157,7 +157,7 @@ module Propono
|
|
157
157
|
@listener.stubs(:requeue_message_on_failure).with(SqsMessage.new(@sqs_message2), exception)
|
158
158
|
@listener.send(:read_messages_from_queue, queue_url, 10)
|
159
159
|
end
|
160
|
-
|
160
|
+
|
161
161
|
def test_messages_are_retried_or_abandoned_on_failure
|
162
162
|
queue_url = "test-queue-url"
|
163
163
|
|
@@ -198,7 +198,7 @@ module Propono
|
|
198
198
|
@sqs.expects(:send_message).with(regexp_matches(/https:\/\/queue.amazonaws.com\/[0-9]+\/MyApp-some-topic-failed/), anything)
|
199
199
|
@listener.send(:requeue_message_on_failure, SqsMessage.new(@sqs_message1), StandardError.new)
|
200
200
|
end
|
201
|
-
|
201
|
+
|
202
202
|
def test_message_requeued_if_there_is_an_exception_but_failure_count_less_than_retry_count
|
203
203
|
Propono.config.max_retries = 5
|
204
204
|
message = SqsMessage.new(@sqs_message1)
|
@@ -206,7 +206,7 @@ module Propono
|
|
206
206
|
@sqs.expects(:send_message).with(regexp_matches(/https:\/\/queue.amazonaws.com\/[0-9]+\/MyApp-some-topic$/), anything)
|
207
207
|
@listener.send(:requeue_message_on_failure, message, StandardError.new)
|
208
208
|
end
|
209
|
-
|
209
|
+
|
210
210
|
def test_message_requeued_if_there_is_an_exception_but_failure_count_exceeds_than_retry_count
|
211
211
|
Propono.config.max_retries = 5
|
212
212
|
message = SqsMessage.new(@sqs_message1)
|
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.
|
4
|
+
version: 1.3.0
|
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-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -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.
|
182
|
+
rubygems_version: 2.1.9
|
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
|