propono 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/propono.rb +2 -1
- data/lib/propono/components/queue_subscription.rb +4 -2
- data/lib/propono/configuration.rb +2 -1
- data/lib/propono/services/queue_listener.rb +1 -0
- data/lib/propono/version.rb +1 -1
- data/test/components/queue_subscription_test.rb +22 -4
- data/test/configuration_test.rb +6 -0
- data/test/propono_test.rb +9 -0
- data/test/services/queue_listener_test.rb +7 -0
- 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: d5f84182f9c9e4875a47a3ac2875a4982500831e
|
|
4
|
+
data.tar.gz: 1b75f8844c07e4b9294584a8ca21e2658a7a9f50
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 32730a332521b97195a04228553fa44d01299afd182e64688ee35059dd97fdd46460b600424e6cd4d2e89819733449e63eb2eb9212f58a5d017ba40498021133
|
|
7
|
+
data.tar.gz: 1e0f553345f7df641ce0ede23404aae1c436dabefc24b6d336eec7360665fb94c65265b335382d5d2b19e89c0d9d38a85bf5bbf512ee52e7792b23df5d7f6de1
|
data/CHANGELOG.md
CHANGED
data/lib/propono.rb
CHANGED
|
@@ -67,7 +67,8 @@ module Propono
|
|
|
67
67
|
# @param [Hash] options
|
|
68
68
|
# * protocol: :udp
|
|
69
69
|
def self.publish(topic, message, options = {})
|
|
70
|
-
|
|
70
|
+
suffixed_topic = "#{topic}#{Propono.config.queue_suffix}"
|
|
71
|
+
Publisher.publish(suffixed_topic, message, options)
|
|
71
72
|
end
|
|
72
73
|
|
|
73
74
|
# Creates a new SNS-SQS subscription on the specified topic.
|
|
@@ -14,17 +14,19 @@ module Propono
|
|
|
14
14
|
|
|
15
15
|
def initialize(topic_id)
|
|
16
16
|
@topic_id = topic_id
|
|
17
|
+
@suffixed_topic_id = "#{topic_id}#{Propono.config.queue_suffix}"
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
def create
|
|
20
|
-
|
|
21
|
+
raise ProponoError.new("topic_id is nil") unless @topic_id
|
|
22
|
+
@topic = TopicCreator.find_or_create(@suffixed_topic_id)
|
|
21
23
|
@queue = QueueCreator.find_or_create(queue_name)
|
|
22
24
|
sns.subscribe(@topic.arn, @queue.arn, 'sqs')
|
|
23
25
|
sqs.set_queue_attributes(@queue.url, "Policy", generate_policy)
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
def queue_name
|
|
27
|
-
@queue_name ||= "#{Propono.config.application_name.gsub(" ", "_")}-#{@
|
|
29
|
+
@queue_name ||= "#{Propono.config.application_name.gsub(" ", "_")}-#{@suffixed_topic_id}"
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
private
|
|
@@ -6,7 +6,7 @@ module Propono
|
|
|
6
6
|
class Configuration
|
|
7
7
|
|
|
8
8
|
SETTINGS = [
|
|
9
|
-
:access_key, :secret_key, :queue_region,
|
|
9
|
+
:access_key, :secret_key, :queue_region, :queue_suffix,
|
|
10
10
|
:application_name,
|
|
11
11
|
:udp_host, :udp_port,
|
|
12
12
|
:tcp_host, :tcp_port,
|
|
@@ -16,6 +16,7 @@ module Propono
|
|
|
16
16
|
|
|
17
17
|
def initialize
|
|
18
18
|
self.logger = Propono::Logger.new
|
|
19
|
+
self.queue_suffix = ""
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
SETTINGS.each do |setting|
|
data/lib/propono/version.rb
CHANGED
|
@@ -2,10 +2,21 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
|
2
2
|
|
|
3
3
|
module Propono
|
|
4
4
|
class QueueSubscriptionTest < Minitest::Test
|
|
5
|
+
def setup
|
|
6
|
+
super
|
|
7
|
+
@suffix = "-suf"
|
|
8
|
+
Propono.config.queue_suffix = @suffix
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def teardown
|
|
12
|
+
super
|
|
13
|
+
Propono.config.queue_suffix = ""
|
|
14
|
+
end
|
|
15
|
+
|
|
5
16
|
def test_create_topic
|
|
6
17
|
topic_id = 'foobar'
|
|
7
18
|
topic = Topic.new(topic_id)
|
|
8
|
-
TopicCreator.expects(:find_or_create).with(topic_id).returns(topic)
|
|
19
|
+
TopicCreator.expects(:find_or_create).with("#{topic_id}#{@suffix}").returns(topic)
|
|
9
20
|
QueueSubscription.create(topic_id)
|
|
10
21
|
end
|
|
11
22
|
|
|
@@ -28,7 +39,7 @@ module Propono
|
|
|
28
39
|
topic_id = "Foobar"
|
|
29
40
|
subscription = QueueSubscription.new(topic_id)
|
|
30
41
|
|
|
31
|
-
assert_equal subscription.send(:queue_name)
|
|
42
|
+
assert_equal "MyApp-Foobar#{@suffix}", subscription.send(:queue_name)
|
|
32
43
|
end
|
|
33
44
|
|
|
34
45
|
def test_subscription_queue_name_with_spaces
|
|
@@ -37,7 +48,7 @@ module Propono
|
|
|
37
48
|
topic_id = "Foobar"
|
|
38
49
|
subscription = QueueSubscription.new(topic_id)
|
|
39
50
|
|
|
40
|
-
assert_equal subscription.send(:queue_name)
|
|
51
|
+
assert_equal "My_App-Foobar#{@suffix}", subscription.send(:queue_name)
|
|
41
52
|
end
|
|
42
53
|
|
|
43
54
|
def test_create_calls_subscribe
|
|
@@ -77,8 +88,15 @@ module Propono
|
|
|
77
88
|
assert_equal queue, subscription.queue
|
|
78
89
|
end
|
|
79
90
|
|
|
91
|
+
def test_create_raises_with_nil_topic
|
|
92
|
+
subscription = QueueSubscription.new(nil)
|
|
93
|
+
assert_raises ProponoError do
|
|
94
|
+
subscription.create
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
80
98
|
def test_generate_policy
|
|
81
|
-
skip"TODO - Implement this test."
|
|
99
|
+
skip "TODO - Implement this test."
|
|
82
100
|
end
|
|
83
101
|
end
|
|
84
102
|
end
|
data/test/configuration_test.rb
CHANGED
|
@@ -43,6 +43,12 @@ module Propono
|
|
|
43
43
|
assert_equal application_name, Propono.config.application_name
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
def test_queue_suffix
|
|
47
|
+
queue_suffix = "test-application-name"
|
|
48
|
+
Propono.config.queue_suffix = queue_suffix
|
|
49
|
+
assert_equal queue_suffix, Propono.config.queue_suffix
|
|
50
|
+
end
|
|
51
|
+
|
|
46
52
|
def test_udp_host
|
|
47
53
|
val = "test-application-name"
|
|
48
54
|
Propono.config.udp_host = val
|
data/test/propono_test.rb
CHANGED
|
@@ -9,6 +9,15 @@ module Propono
|
|
|
9
9
|
Propono.publish(topic, message)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
def test_publish_sets_suffix_publish
|
|
13
|
+
Propono.config.queue_suffix = "-bar"
|
|
14
|
+
topic = "foo"
|
|
15
|
+
Publisher.expects(:publish).with("foo-bar", '', {})
|
|
16
|
+
Propono.publish(topic, "")
|
|
17
|
+
ensure
|
|
18
|
+
Propono.config.queue_suffix = ""
|
|
19
|
+
end
|
|
20
|
+
|
|
12
21
|
def test_subscribe_by_queue_calls_subscribe
|
|
13
22
|
topic = 'foobar'
|
|
14
23
|
Subscriber.expects(:subscribe_by_queue).with(topic)
|
|
@@ -32,6 +32,13 @@ module Propono
|
|
|
32
32
|
@listener.listen
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
+
def test_listen_raises_with_nil_topic
|
|
36
|
+
listener = QueueListener.new(nil) {}
|
|
37
|
+
assert_raises ProponoError do
|
|
38
|
+
listener.listen
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
35
42
|
def test_read_messages_should_subscribe
|
|
36
43
|
QueueSubscription.expects(create: mock(queue: mock(url: {})))
|
|
37
44
|
@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: 0.
|
|
4
|
+
version: 0.10.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: 2013-
|
|
12
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: fog
|