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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cbff5dcb118c99e3f7ff39f3cfc172e478edb5e
4
- data.tar.gz: 619b6da2339dd1a0c9feea52b4851e0735f6a826
3
+ metadata.gz: f1ff92b911ef9f4ae48012a57710e6dc36f4afa7
4
+ data.tar.gz: da17719ba6d0d5b9914892e36156af76888df5e0
5
5
  SHA512:
6
- metadata.gz: bf7e492a492a3a31dd40fede408e1b084f996aff7b057f1747617a10f8d217028d2dca4541d381dd0da70612e89ca2b91b4d3a91696036e057a3504940760b47
7
- data.tar.gz: f9fec93fc0c85902123a9b6d5c608ef711a89853e01502fd70d3c563797889707b14687522bd302abe5eeb039951d1a43a1bf94add6286955c6675533796dacb
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 recieved The Best Message Ever"
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
- **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. It's therefore advisable to do a `Thread.join` on the thread that is returned from the final call to `publish`.
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
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  namespace :test do
13
13
  Rake::TestTask.new(:local) do |t|
14
- t.pattern = "test/{components/,services/,helpers/,}*_test.rb"
14
+ t.pattern = "test/{components/,services/,utils/,}*_test.rb"
15
15
  end
16
16
  end
17
17
 
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 = body.symbolize_keys
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 = options.symbolize_keys
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).symbolize_keys
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 recieving messags without ids is deprecated")
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).symbolize_keys
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 recieving messags without ids is deprecated")
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
@@ -1,3 +1,3 @@
1
1
  module Propono
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -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]
@@ -7,6 +7,7 @@ module Propono
7
7
  end
8
8
 
9
9
  def setup
10
+ super
10
11
  Propono.config.access_key = "test-access-key"
11
12
  Propono.config.secret_key = "test-secret-key"
12
13
  Propono.config.queue_region = "test-queue-region"
@@ -7,6 +7,7 @@ module Propono
7
7
  end
8
8
 
9
9
  def setup
10
+ super
10
11
  Propono.config.access_key = "test-access-key"
11
12
  Propono.config.secret_key = "test-secret-key"
12
13
  Propono.config.queue_region = "us-east-1"
@@ -4,6 +4,7 @@ module Propono
4
4
  class ConfigurationTest < Minitest::Test
5
5
 
6
6
  def setup
7
+ super
7
8
  Propono.instance_variable_set("@config", nil)
8
9
  end
9
10
 
@@ -11,6 +11,8 @@ module Propono
11
11
  message_received = false
12
12
  slow_message_received = false
13
13
 
14
+ Propono.drain_queue(slow_topic)
15
+ Propono.drain_queue(topic)
14
16
  Propono.subscribe_by_queue(topic)
15
17
 
16
18
  thread = Thread.new do
@@ -8,6 +8,7 @@ module Propono
8
8
  flunks = []
9
9
  message_received = false
10
10
 
11
+ Propono.drain_queue(topic)
11
12
  Propono.subscribe_by_queue(topic)
12
13
 
13
14
  thread = Thread.new do
@@ -11,6 +11,7 @@ module Propono
11
11
  Propono.config.tcp_host = "localhost"
12
12
  Propono.config.tcp_port = 20009
13
13
 
14
+ Propono.drain_queue(topic)
14
15
  Propono.subscribe_by_queue(topic)
15
16
 
16
17
  sqs_thread = Thread.new do
@@ -10,6 +10,7 @@ module Propono
10
10
 
11
11
  Propono.config.udp_port = 20001
12
12
 
13
+ Propono.drain_queue(topic)
13
14
  Propono.subscribe_by_queue(topic)
14
15
 
15
16
  sqs_thread = Thread.new do
@@ -10,6 +10,7 @@ module Propono
10
10
 
11
11
  Propono.config.udp_port = 20002
12
12
 
13
+ Propono.drain_queue(topic)
13
14
  Propono.subscribe_by_queue(topic)
14
15
 
15
16
  sqs_thread = Thread.new do
@@ -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
- Propono.config.logger.expects(:info).with() {|x| x =~ /^Propono \[abc\]: Publishing bar to foo via sns.*/}
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
@@ -20,6 +20,7 @@ class Minitest::Test
20
20
  config.secret_key = "test-secret-key"
21
21
  config.queue_region = "us-east-1"
22
22
  config.application_name = "MyApp"
23
+ config.queue_suffix = ""
23
24
 
24
25
  config.logger.stubs(:debug)
25
26
  config.logger.stubs(:info)
@@ -22,7 +22,7 @@ module Propono
22
22
  }
23
23
  }
24
24
 
25
- assert_equal expected, input.symbolize_keys
25
+ assert_equal expected, Propono::Utils.symbolize_keys(input)
26
26
  end
27
27
  end
28
28
  end
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.3.0
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: 2014-07-12 00:00:00.000000000 Z
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.1.9
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:
@@ -1,10 +0,0 @@
1
- class Hash
2
- def symbolize_keys
3
- inject({}) do |result, (key, value)|
4
- new_key = key.is_a?(String) ? key.to_sym : key
5
- new_value = value.is_a?(Hash) ? value.symbolize_keys : value
6
- result[new_key] = new_value
7
- result
8
- end
9
- end
10
- end