propono 1.3.0 → 1.4.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 +6 -0
- data/README.md +22 -3
- data/Rakefile +1 -1
- data/lib/propono.rb +2 -2
- data/lib/propono/components/sqs_message.rb +1 -1
- data/lib/propono/services/publisher.rb +1 -1
- data/lib/propono/services/tcp_listener.rb +2 -2
- data/lib/propono/services/udp_listener.rb +2 -2
- data/lib/propono/utils.rb +17 -0
- data/lib/propono/version.rb +1 -1
- data/test/components/aws_config_test.rb +9 -8
- data/test/components/sns_test.rb +1 -0
- data/test/components/sqs_test.rb +1 -0
- data/test/configuration_test.rb +1 -0
- data/test/integration/slow_queue_test.rb +2 -0
- data/test/integration/sns_to_sqs_test.rb +1 -0
- data/test/integration/tcp_to_sqs_test.rb +1 -0
- data/test/integration/udp_proxy_test.rb +1 -0
- data/test/integration/udp_to_sqs_test.rb +1 -0
- data/test/services/publisher_test.rb +2 -1
- data/test/test_helper.rb +1 -0
- data/test/{helpers → utils}/hash_test.rb +1 -1
- metadata +22 -22
- data/lib/propono/helpers/hash.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1ff92b911ef9f4ae48012a57710e6dc36f4afa7
|
4
|
+
data.tar.gz: da17719ba6d0d5b9914892e36156af76888df5e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4188aeee17c98854395491b0453b5f51161209473f9ccc9a2692e499f529ba19d5eaa777ecb874ad1b8b5b61057110b0e8cfc940c0cd9c8ec9f9da67a42f7eeb
|
7
|
+
data.tar.gz: 01ab6936c889bf091dac35b44a3bee9351a597f4ddc1fd5cb378b752027c926e86461dc66bf0a434022e4e86f9a0b4f7938635d0d56027e32ca09ccd5f522db0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 1.4.0 / 2014-07-12
|
2
|
+
* [FEATURE] Move symbolize_keys to Propono namespace to avoid ActiveSupport conflict (:blue_heart: @tardate)
|
3
|
+
* [BUGFIX] Drain integration tests drain queues before starting (:blue_heart: @tardate)
|
4
|
+
* [BUGFIX] Fix typos in log messages (:blue_heart: @tardate)
|
5
|
+
* [BUGFIX] Fix issue with tests failing when ran in a certain order
|
6
|
+
|
1
7
|
# 1.3.0 / 2014-07-12
|
2
8
|
* [FEATURE] Add {async: false} option to publisher
|
3
9
|
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
Propono is a [pub/sub](http://en.wikipedia.org/wiki/Publish-subscribe_pattern) gem built on top of Amazon Web Services (AWS). It uses Simple Notification Service (SNS) and Simple Queue Service (SQS) to seamlessly pass messages throughout your infrastructure.
|
8
8
|
|
9
|
-
It's beautifully simple to use.
|
9
|
+
It's beautifully simple to use. [Watch an introduction](https://www.youtube.com/watch?v=ZM3-Gl5DVgM)
|
10
10
|
|
11
11
|
```ruby
|
12
12
|
# On Machine A
|
@@ -18,7 +18,7 @@ end
|
|
18
18
|
Propono.publish('some-topic', "The Best Message Ever")
|
19
19
|
|
20
20
|
# Output on Machine A a second later.
|
21
|
-
# - "I just
|
21
|
+
# - "I just received The Best Message Ever"
|
22
22
|
```
|
23
23
|
|
24
24
|
## Installation
|
@@ -39,6 +39,11 @@ The first thing to do is setup some configuration keys for Propono. It's best to
|
|
39
39
|
Propono.config.access_key = "access-key" # From AWS
|
40
40
|
Propono.config.secret_key = "secret-key" # From AWS
|
41
41
|
Propono.config.queue_region = "queue-region" # From AWS
|
42
|
+
|
43
|
+
# Or use the IAM profile of the machine
|
44
|
+
Propono.config.use_iam_profile = true
|
45
|
+
Propono.config.queue_region = "queue-region" # From AWS
|
46
|
+
|
42
47
|
```
|
43
48
|
|
44
49
|
You can then start publishing messages easily from anywhere in your codebase.
|
@@ -58,7 +63,17 @@ end
|
|
58
63
|
```
|
59
64
|
In the background, Propono is automatically setting up a queue using SQS, a notification system using SNS, and gluing them all together for you. But you don't have to worry about any of that.
|
60
65
|
|
61
|
-
**
|
66
|
+
**Does it matter what I set my `application_name` to?**
|
67
|
+
For a simple publisher and subscriber deployment, no.
|
68
|
+
However, the `application_name` has a direct impact on subscriber behaviour when more than one is in play.
|
69
|
+
This is because a queue is established for each application_name/topic combination. In practice:
|
70
|
+
* subscribers that share the same `application_name` will act as multiple workers on the same queue. Only one will get to process each message.
|
71
|
+
* subscribers that have a different `application_name` will each get a copy of a message to process independently i.e. acts as a one-to-many broadcast.
|
72
|
+
|
73
|
+
|
74
|
+
**Note for using in Rake tasks and similar:** Propono spawns new threads for messages sent via SNS. If your application ends before the final thread is executed, then the last message might not send. There are two options to help you here:
|
75
|
+
* Pass the `{async: false}` option to Propono.publish. (This was introduced in 1.3.0)
|
76
|
+
* Do a `Thread#join` on each thread that is returned from calls to `publish`.
|
62
77
|
|
63
78
|
### Using TCP for messages
|
64
79
|
|
@@ -124,8 +139,12 @@ The following configuration settings are available:
|
|
124
139
|
|
125
140
|
```
|
126
141
|
Propono.config do |config|
|
142
|
+
# Use AWS access and secret keys
|
127
143
|
config.access_key = "An AWS access key"
|
128
144
|
config.secret_key = "A AWS secret key"
|
145
|
+
# Or use AWS IAM profile of the machine
|
146
|
+
config.use_iam_profile = true
|
147
|
+
|
129
148
|
config.queue_region = "An AWS queue region"
|
130
149
|
config.application_name = "A name unique in your network"
|
131
150
|
config.udp_host = "The host of a machine used for UDP proxying"
|
data/Rakefile
CHANGED
data/lib/propono.rb
CHANGED
@@ -5,8 +5,7 @@ require "propono/version"
|
|
5
5
|
require 'propono/propono_error'
|
6
6
|
require 'propono/logger'
|
7
7
|
require 'propono/configuration'
|
8
|
-
|
9
|
-
require "propono/helpers/hash"
|
8
|
+
require "propono/utils"
|
10
9
|
|
11
10
|
require 'propono/components/aws_config'
|
12
11
|
require 'propono/components/sns'
|
@@ -45,6 +44,7 @@ module Propono
|
|
45
44
|
# * <tt>:queue_region</tt> - The AWS region
|
46
45
|
# * <tt>:application_name</tt> - The name of the application Propono
|
47
46
|
# is included in.
|
47
|
+
# * <tt>:queue_suffix</tt> - Optional string to append to topic and queue names.
|
48
48
|
# * <tt>:udp_host</tt> - If using UDP, the host to send to.
|
49
49
|
# * <tt>:udp_port</tt> - If using UDP, the port to send to.
|
50
50
|
# * <tt>:logger</tt> - A logger object that responds to puts.
|
@@ -9,7 +9,7 @@ module Propono
|
|
9
9
|
body = JSON.parse(@raw_body_json["Message"])
|
10
10
|
|
11
11
|
@raw_message = raw_message
|
12
|
-
@context =
|
12
|
+
@context = Propono::Utils.symbolize_keys body
|
13
13
|
@failure_count = context[:num_failures] || 0
|
14
14
|
@message = context.delete(:message)
|
15
15
|
@receipt_handle = raw_message["receipt_handle"]
|
@@ -17,7 +17,7 @@ module Propono
|
|
17
17
|
raise PublisherError.new("Topic is nil") if topic_id.nil?
|
18
18
|
raise PublisherError.new("Message is nil") if message.nil?
|
19
19
|
|
20
|
-
options =
|
20
|
+
options = Propono::Utils.symbolize_keys options
|
21
21
|
|
22
22
|
@topic_id = topic_id
|
23
23
|
@message = message
|
@@ -29,14 +29,14 @@ module Propono
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def process_tcp_data(tcp_data)
|
32
|
-
json = JSON.parse(tcp_data)
|
32
|
+
json = Propono::Utils.symbolize_keys JSON.parse(tcp_data)
|
33
33
|
|
34
34
|
# Legacy syntax is covered in the else statement
|
35
35
|
# This conditional and the else block will be removed in v1.
|
36
36
|
if json[:id]
|
37
37
|
@processor.call(json[:topic], json[:message], id: json[:id])
|
38
38
|
else
|
39
|
-
Propono.config.logger.info("Sending and
|
39
|
+
Propono.config.logger.info("Sending and receiving messages without ids is deprecated")
|
40
40
|
@processor.call(json[:topic], json[:message])
|
41
41
|
end
|
42
42
|
end
|
@@ -27,14 +27,14 @@ module Propono
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def process_udp_data(udp_data)
|
30
|
-
json = JSON.parse(udp_data)
|
30
|
+
json = Propono::Utils.symbolize_keys JSON.parse(udp_data)
|
31
31
|
|
32
32
|
# Legacy syntax is covered in the else statement
|
33
33
|
# This conditional and the else block will be removed in v1.
|
34
34
|
if json[:id]
|
35
35
|
@processor.call(json[:topic], json[:message], id: json[:id])
|
36
36
|
else
|
37
|
-
Propono.config.logger.info("Sending and
|
37
|
+
Propono.config.logger.info("Sending and receiving messages without ids is deprecated")
|
38
38
|
@processor.call(json[:topic], json[:message])
|
39
39
|
end
|
40
40
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Propono
|
2
|
+
module Utils
|
3
|
+
|
4
|
+
# Returns +hash+ with all primary and nested keys to string values symbolised
|
5
|
+
# To avoid conflicts with ActiveSupport and other libraries that provide Hash symbolisation,
|
6
|
+
# this method is kept within the Propono namespace and not mixed into Hash
|
7
|
+
def self.symbolize_keys(hash)
|
8
|
+
hash.inject({}) do |result, (key, value)|
|
9
|
+
new_key = key.is_a?(String) ? key.to_sym : key
|
10
|
+
new_value = value.is_a?(Hash) ? symbolize_keys(value) : value
|
11
|
+
result[new_key] = new_value
|
12
|
+
result
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/propono/version.rb
CHANGED
@@ -4,23 +4,24 @@ module Propono
|
|
4
4
|
class AwsConfigTest < Minitest::Test
|
5
5
|
|
6
6
|
def setup
|
7
|
+
super
|
7
8
|
@config = Propono::Configuration.new
|
8
|
-
|
9
|
+
|
9
10
|
@config.access_key = "test-access-key"
|
10
11
|
@config.secret_key = "test-secret-key"
|
11
12
|
@config.queue_region = "test-queue-region"
|
12
|
-
|
13
|
+
|
13
14
|
@aws_config = Propono::AwsConfig.new(@config)
|
14
15
|
end
|
15
16
|
|
16
17
|
def test_access_key
|
17
18
|
assert_equal "test-access-key", @aws_config.aws_options[:aws_access_key_id]
|
18
19
|
end
|
19
|
-
|
20
|
+
|
20
21
|
def test_secret_key
|
21
22
|
assert_equal "test-secret-key", @aws_config.aws_options[:aws_secret_access_key]
|
22
23
|
end
|
23
|
-
|
24
|
+
|
24
25
|
def test_region
|
25
26
|
assert_equal "test-queue-region", @aws_config.aws_options[:region]
|
26
27
|
end
|
@@ -28,22 +29,22 @@ module Propono
|
|
28
29
|
def test_no_iam_profile_selected
|
29
30
|
assert ! @aws_config.aws_options.has_key?(:use_iam_profile)
|
30
31
|
end
|
31
|
-
|
32
|
+
|
32
33
|
def test_use_iam_profile
|
33
34
|
@config.use_iam_profile = true
|
34
35
|
assert @aws_config.aws_options[:use_iam_profile]
|
35
36
|
end
|
36
|
-
|
37
|
+
|
37
38
|
def test_selecting_use_iam_profile_results_in_no_access_key
|
38
39
|
@config.use_iam_profile = true
|
39
40
|
assert ! @aws_config.aws_options.has_key?(:aws_access_key_id)
|
40
41
|
end
|
41
|
-
|
42
|
+
|
42
43
|
def test_selecting_use_iam_profile_results_in_no_secret_key
|
43
44
|
@config.use_iam_profile = true
|
44
45
|
assert ! @aws_config.aws_options.has_key?(:aws_secret_access_key)
|
45
46
|
end
|
46
|
-
|
47
|
+
|
47
48
|
def test_region_when_using_iam_profile
|
48
49
|
@config.use_iam_profile = true
|
49
50
|
assert_equal "test-queue-region", @aws_config.aws_options[:region]
|
data/test/components/sns_test.rb
CHANGED
data/test/components/sqs_test.rb
CHANGED
data/test/configuration_test.rb
CHANGED
@@ -39,7 +39,8 @@ module Propono
|
|
39
39
|
def test_publish_logs
|
40
40
|
publisher = Publisher.new("foo", "bar")
|
41
41
|
publisher.instance_variable_set(:@id, 'abc')
|
42
|
-
|
42
|
+
publisher.stubs(:publish_via_sns)
|
43
|
+
Propono.config.logger.expects(:info).with {|x| x =~ /^Propono \[abc\]: Publishing bar to foo via sns.*/}
|
43
44
|
publisher.send(:publish)
|
44
45
|
end
|
45
46
|
|
data/test/test_helper.rb
CHANGED
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.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MalcyL
|
@@ -9,90 +9,90 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-02-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
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
27
|
version: '1.15'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: bundler
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - ~>
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '1.3'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - ~>
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '1.3'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rake
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: mocha
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: yard
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: minitest
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - ~>
|
88
|
+
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: 5.0.8
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - ~>
|
95
|
+
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: 5.0.8
|
98
98
|
description: Pub / Sub Library using Amazon Web Services
|
@@ -103,8 +103,8 @@ executables: []
|
|
103
103
|
extensions: []
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
|
-
- .gitignore
|
107
|
-
- .travis.yml
|
106
|
+
- ".gitignore"
|
107
|
+
- ".travis.yml"
|
108
108
|
- CHANGELOG.md
|
109
109
|
- CONTRIBUTING.md
|
110
110
|
- Gemfile
|
@@ -121,7 +121,6 @@ files:
|
|
121
121
|
- lib/propono/components/sqs_message.rb
|
122
122
|
- lib/propono/components/topic.rb
|
123
123
|
- lib/propono/configuration.rb
|
124
|
-
- lib/propono/helpers/hash.rb
|
125
124
|
- lib/propono/logger.rb
|
126
125
|
- lib/propono/propono_error.rb
|
127
126
|
- lib/propono/services/publisher.rb
|
@@ -131,6 +130,7 @@ files:
|
|
131
130
|
- lib/propono/services/tcp_listener.rb
|
132
131
|
- lib/propono/services/topic_creator.rb
|
133
132
|
- lib/propono/services/udp_listener.rb
|
133
|
+
- lib/propono/utils.rb
|
134
134
|
- lib/propono/version.rb
|
135
135
|
- propono.gemspec
|
136
136
|
- test/components/aws_config_test.rb
|
@@ -142,7 +142,6 @@ files:
|
|
142
142
|
- test/components/topic_test.rb
|
143
143
|
- test/config.yml.example
|
144
144
|
- test/configuration_test.rb
|
145
|
-
- test/helpers/hash_test.rb
|
146
145
|
- test/integration/integration_test.rb
|
147
146
|
- test/integration/slow_queue_test.rb
|
148
147
|
- test/integration/sns_to_sqs_test.rb
|
@@ -159,6 +158,7 @@ files:
|
|
159
158
|
- test/services/topic_creator_test.rb
|
160
159
|
- test/services/udp_listener_test.rb
|
161
160
|
- test/test_helper.rb
|
161
|
+
- test/utils/hash_test.rb
|
162
162
|
homepage: ''
|
163
163
|
licenses:
|
164
164
|
- AGPL3
|
@@ -169,17 +169,17 @@ require_paths:
|
|
169
169
|
- lib
|
170
170
|
required_ruby_version: !ruby/object:Gem::Requirement
|
171
171
|
requirements:
|
172
|
-
- -
|
172
|
+
- - ">="
|
173
173
|
- !ruby/object:Gem::Version
|
174
174
|
version: '0'
|
175
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
|
-
- -
|
177
|
+
- - ">="
|
178
178
|
- !ruby/object:Gem::Version
|
179
179
|
version: '0'
|
180
180
|
requirements: []
|
181
181
|
rubyforge_project:
|
182
|
-
rubygems_version: 2.
|
182
|
+
rubygems_version: 2.2.2
|
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
|
@@ -193,7 +193,6 @@ test_files:
|
|
193
193
|
- test/components/topic_test.rb
|
194
194
|
- test/config.yml.example
|
195
195
|
- test/configuration_test.rb
|
196
|
-
- test/helpers/hash_test.rb
|
197
196
|
- test/integration/integration_test.rb
|
198
197
|
- test/integration/slow_queue_test.rb
|
199
198
|
- test/integration/sns_to_sqs_test.rb
|
@@ -210,4 +209,5 @@ test_files:
|
|
210
209
|
- test/services/topic_creator_test.rb
|
211
210
|
- test/services/udp_listener_test.rb
|
212
211
|
- test/test_helper.rb
|
212
|
+
- test/utils/hash_test.rb
|
213
213
|
has_rdoc:
|
data/lib/propono/helpers/hash.rb
DELETED