propono 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTk2ZTQ1YmMxYTg4NzdiOWEyZDQ1ZWQyOTI4N2QyMGE4ZTA5OWRiOQ==
4
+ ZDQ0NzcyNzRmNTc5YjM2N2RjYTRiY2FjMDZmOGFiMTZiZTg1NmZiNQ==
5
5
  data.tar.gz: !binary |-
6
- ZmUwY2I2M2E4ZjQ4ZTAxYzIwNzI4OTVjNWQ1OTkyYmFhYmM4Njk4OA==
6
+ MGY0OTNiNDExMjk4M2U2OTk2NjNkNzNmNWViYzlhMGU5MTM0NjJjNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTI1OWEzZGUwZTMzNzllNTYyNTE0NGZmOTZiOWUxZjJlYzUyNzY1NmQzMGZk
10
- NTExYzYzNjE5NmI4NGE1Y2ZkODEzMzNkNzM2NzI1ZDAyMDFjYjQ0ZWIxYzhl
11
- OGQ2NzBhZDlmNWQxZGYxMzUyMDJkN2I5YTAwMGM1YjIwMzYwMzU=
9
+ ODJiYTFjMGYyMjNlMjhkNzU0NGQ3ZTVkYTc2MGU0ZjQ0Y2IxMTU3OTRmMDZh
10
+ ZDc1MDg1NWZhYjM5YzE4MzUyMDgwOWRlM2ExOTVhNzBlMGE3MTk3MGNlYWFh
11
+ ZGYwNWI1ZTg0OWVkNGE2YjZmM2M3ZTI1YjhiNTczMTYzNGNhMjQ=
12
12
  data.tar.gz: !binary |-
13
- ZjFhYzMxYzgxNmZmNWM5MmQ1ODkwMTJlYzY4N2ZmNTE2NTMwYTY3MTA3YWVk
14
- YjAxYjEyZjgwMjA4MmMxNzZjMDk5ZDA2M2RlZDc5ZmExNzRlNzQ2MTk2Mjc0
15
- ZDY2OWU0ZjI2MmE2NWFjOWEyZDY5MGQyMTIwNTdhNWViOTI1Zjc=
13
+ YWI4ZDIxYzRjNGVkYzk3ZjdlZDBlNDZhOGMyMjg2MWY2ZTU1MDczOGM5NWRl
14
+ NWIyZTZkOGNmYmI4MDFiODYwZTY5MTZhZDk0NzMwMjc0ZDJiNGZlNzMwOTli
15
+ ZDcyMWQyNzhiMTZjMjZhZTJkNzk5NjYzYjA3ZjU2NDE5MGFhMDQ=
data/.travis.yml CHANGED
@@ -1,8 +1,13 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 1.9.3
3
4
  - 2.0.0
5
+ - rbx-2.1.1
4
6
  script:
5
7
  - bundle exec rake test:local
6
8
  addons:
7
9
  code_climate:
8
10
  repo_token: 88dd239bc2e0010742a42a4e0234b4decd19b46d0e9d3408d8b1fe0f96dd8fc1
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: rbx-2.1.1
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- # 0.7.0 / Unreleased
1
+ # 0.8.0 / 2013-11-01
2
+
3
+ * [FEATURE] SNS publish now delegates to a thread pool. The SNS response can be accessed via a future.
4
+
5
+ # 0.7.0 / 2013-10-23
2
6
 
3
7
  * [FEATURE] Add TCP publish and listen methods.
4
8
 
data/lib/propono.rb CHANGED
@@ -2,6 +2,8 @@
2
2
  #
3
3
  # Propono is a pub/sub 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.
4
4
 
5
+ require "thread/pool"
6
+
5
7
  require "propono/version"
6
8
  require 'propono/propono_error'
7
9
  require 'propono/logger'
@@ -26,6 +28,8 @@ require "propono/services/tcp_listener"
26
28
  # It uses Simple Notification Service (SNS) and Simple Queue Service (SQS)
27
29
  # to seamlessly pass messages throughout your infrastructure.
28
30
  module Propono
31
+
32
+ WORKER_POOL = Thread.pool(4)
29
33
 
30
34
  # Propono configuration settings.
31
35
  #
@@ -1,4 +1,5 @@
1
1
  require 'socket'
2
+ require 'thread/future'
2
3
 
3
4
  module Propono
4
5
  class PublisherError < ProponoError
@@ -31,7 +32,9 @@ module Propono
31
32
  def publish_via_sns
32
33
  topic = TopicCreator.find_or_create(topic_id)
33
34
  msg = message.is_a?(String) ? message : message.to_json
34
- sns.publish(topic.arn, msg)
35
+ Thread.future(WORKER_POOL) do
36
+ sns.publish(topic.arn, msg)
37
+ end
35
38
  end
36
39
 
37
40
  def publish_via_udp
@@ -23,7 +23,6 @@ module Propono
23
23
  private
24
24
 
25
25
  def read_messages
26
- #response = sqs.receive_message( queue_url, options = { 'MaxNumberOfMessages' => 10 } )
27
26
  response = sqs.receive_message( queue_url, {'MaxNumberOfMessages' => 10} )
28
27
  messages = response.body['Message']
29
28
  if messages.empty?
@@ -1,3 +1,3 @@
1
1
  module Propono
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
data/propono.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "fog", "~> 1.15.0"
22
+ spec.add_dependency "thread", "~> 0.1.1"
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 1.3"
24
25
  spec.add_development_dependency "rake"
@@ -49,7 +49,7 @@ module Propono
49
49
  sns.expects(:publish).with(topic_arn, message)
50
50
  publisher = Publisher.new(topic, message)
51
51
  publisher.stubs(sns: sns)
52
- publisher.send(:publish_via_sns)
52
+ ~publisher.send(:publish_via_sns)
53
53
  end
54
54
 
55
55
  def test_publish_via_sns_should_accept_a_hash_for_message
@@ -64,7 +64,22 @@ module Propono
64
64
  sns.expects(:publish).with(topic_arn, message.to_json)
65
65
  publisher = Publisher.new(topic, message)
66
66
  publisher.stubs(sns: sns)
67
- publisher.send(:publish_via_sns)
67
+ ~publisher.send(:publish_via_sns)
68
+ end
69
+
70
+ def test_publish_via_sns_should_return_future_of_the_sns_response
71
+ topic = "topic123"
72
+ message = "message123"
73
+ topic_arn = "arn123"
74
+ topic = Topic.new(topic_arn)
75
+
76
+ TopicCreator.stubs(find_or_create: topic)
77
+
78
+ sns = mock()
79
+ sns.expects(:publish).with(topic_arn, message).returns(:response)
80
+ publisher = Publisher.new(topic, message)
81
+ publisher.stubs(sns: sns)
82
+ assert_same :response, publisher.send(:publish_via_sns).value
68
83
  end
69
84
 
70
85
  def test_publish_via_sns_should_propogate_exception_on_topic_creation_error
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.7.0
4
+ version: 0.8.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-10-23 00:00:00.000000000 Z
12
+ date: 2013-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
27
  version: 1.15.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: thread
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 0.1.1
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: 0.1.1
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: bundler
30
44
  requirement: !ruby/object:Gem::Requirement