circuitry 3.1.3 → 3.1.4

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: 1f3c99a64adc915007123a1956871036f326888b
4
- data.tar.gz: 8e87c4341121bbee53f2eab1de36a3ac7c946f00
3
+ metadata.gz: 99b3ddd979a6bea1d3a1dfaba8222705d54d0444
4
+ data.tar.gz: e6a6a65560048bb702b66f6c5ace6d04449470e3
5
5
  SHA512:
6
- metadata.gz: 1109edbb48c25e003d4b1ecd0254d955cd5dd47109414064cedc2bc4fc8af45b11b0f962a04de15dbb8960df8368efb6f379058d053cfa6d3801418cc31da4a4
7
- data.tar.gz: 81416baf0e0e6090230081ae0577670bb36ec1740e85ed1ba752475532b88fe329f8045a36c58d2ba1ad9e28c9dd0dc6202cc5770a5bab17fd83dd4250477fa2
6
+ metadata.gz: c7771d7687a28ea226bcff384cfa30baebabbd780983e4bdb593abc377f128e09a2d72d6dacfa3f43615e5b48153f2433d97559cfd8d4a54175dd6993a96a9c4
7
+ data.tar.gz: eee566c00b1239c2e87d80dff6dbb04573b5cc9bf0c43f58c6b937410548763c8d82745dc4ae4a9c0d2957e378c2b6cd57c7791d006e1ecba6e39e3c20e0b127
@@ -1,3 +1,11 @@
1
+ ## Circuitry 3.1.4 (Apr 21, 2016)
2
+
3
+ * Fixed issue with `circuitry help` missing dependency. *Matt Huggins*
4
+ * Fixed issue with `circuitry:setup` rake task when no topics are defined. *Matt Huggins*
5
+ * Fixed issues with `circuitry:setup` rake task in vanilla Ruby projects. *Matt Huggins*
6
+ * Removed subscriber flush middleware in favor of an inline flush. *Matt Huggins*
7
+ * Added SNS internal failure as a retriable error. *Matt Huggins*
8
+
1
9
  ## Circuitry 3.1.3 (Mar 23, 2016)
2
10
 
3
11
  * Added retries for message publishing if there's an SNS connection failure. *Matt Huggins*
data/README.md CHANGED
@@ -7,9 +7,26 @@ Decouple ruby applications using [SNS](http://aws.amazon.com/sns/) fanout with [
7
7
 
8
8
  A Circuitry publisher application can broadcast events which can be fanned out to any number of SQS queues. This technique is a [common approach](http://docs.aws.amazon.com/sns/latest/dg/SNS_Scenarios.html) to implementing an enterprise message bus. For example, applications which care about billing or new user onboarding can react when a user signs up, without the origin web application being concerned with those domains. In this way, new capabilities can be connected to an enterprise system without change proliferation.
9
9
 
10
- ## How is Circuitry different from Shoryuken?
10
+ ## Features
11
11
 
12
- [Shoryuken](https://github.com/phstc/shoryuken) is a way to leverage SQS to execute workloads later within the same application. Circuitry is a way to execute any number of workloads in different applications after an event has taken place.
12
+ What circuitry provides:
13
+
14
+ * *Decoupling:* apps can send and receive messages to each other without explicitly coding destinations into your app.
15
+ * *Fan-out:* multiple queues (i.e.: multiple apps) can receive the same message by publishing it a single time.
16
+ * *Reliability:* if your app goes down (intentionally or otherwise), messages will be waiting in the queue whenever it starts up again.
17
+ * *Speed:* because it's built on AWS, message delivery and receipt is *fast*.
18
+ * *Duplication:* although SQS messages can be delivered multiple times, circuitry safeguards to ensure they're only received by your app once.
19
+ * *Retries:* if a received message fails to be processed, it will be retried (unless otherwise configured).
20
+ * *Customization:* configure your publisher and subscriber to behave the way each app independently expects.
21
+
22
+ What circuitry does not provide:
23
+
24
+ * *Ordering:* messages may not arrive in the order they were sent.
25
+ * *Scheduling:* messages are processed as they're received.
26
+
27
+ ## Example
28
+
29
+ A [circuitry-example](https://github.com/kapost/circuitry-example) app is available to quickly try the gem on your own AWS account.
13
30
 
14
31
  ## Installation
15
32
 
@@ -154,6 +171,8 @@ two methods: the circuitry CLI or the `rake circuitry:setup` task. The rake task
154
171
  subscriber queue and publishing topics that are configured within your application.
155
172
 
156
173
  ```ruby
174
+ require 'circuitry/tasks'
175
+
157
176
  Circuitry.subscriber_config do |c|
158
177
  c.queue_name = 'myapp-production-events'
159
178
  c.topic_names = ['theirapp-production-stuff-created', 'theirapp-production-stuff-deleted']
@@ -555,16 +574,6 @@ your middleware:
555
574
  * `#clear`: Removes all middleware classes from the chain.
556
575
  * `middleware.clear`
557
576
 
558
- ### Default Subscriber Middleware:
559
-
560
- * `Circuitry::Middleware::Entries::Flush`: ensures any pending async publishes are run after a
561
- message is received. Useful for publishes that happen as a result of processing received
562
- messages.
563
-
564
- ### Default Publisher Middleware:
565
-
566
- None.
567
-
568
577
  ## Testing
569
578
 
570
579
  Circuitry provides a simple option for testing publishing and subscribing without actually hitting
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'aws-sdk', '~> 2'
23
23
  spec.add_dependency 'retries', '~> 0.0.5'
24
24
  spec.add_dependency 'virtus', '~> 1.0'
25
+ spec.add_dependency 'thor'
25
26
 
26
27
  spec.add_development_dependency 'bundler', '~> 1.8'
27
28
  spec.add_development_dependency 'codeclimate-test-reporter'
@@ -34,5 +35,4 @@ Gem::Specification.new do |spec|
34
35
  spec.add_development_dependency 'redis'
35
36
  spec.add_development_dependency 'rspec', '~> 3.2'
36
37
  spec.add_development_dependency 'rspec-its', '~> 1.2'
37
- spec.add_development_dependency 'thor'
38
38
  end
@@ -18,23 +18,23 @@ require 'circuitry/version'
18
18
  module Circuitry
19
19
  class << self
20
20
  def subscriber_config
21
- @_sub_config ||= Config::SubscriberSettings.new
22
- yield @_sub_config if block_given?
23
- @_sub_config
21
+ @sub_config ||= Config::SubscriberSettings.new
22
+ yield @sub_config if block_given?
23
+ @sub_config
24
24
  end
25
25
 
26
26
  def subscriber_config=(options)
27
- @_sub_config = Config::SubscriberSettings.new(options)
27
+ @sub_config = Config::SubscriberSettings.new(options)
28
28
  end
29
29
 
30
30
  def publisher_config
31
- @_pub_config ||= Config::PublisherSettings.new
32
- yield @_pub_config if block_given?
33
- @_pub_config
31
+ @pub_config ||= Config::PublisherSettings.new
32
+ yield @pub_config if block_given?
33
+ @pub_config
34
34
  end
35
35
 
36
36
  def publisher_config=(options)
37
- @_pub_config = Config::PublisherSettings.new(options)
37
+ @pub_config = Config::PublisherSettings.new(options)
38
38
  end
39
39
 
40
40
  def publish(topic_name, object, options = {})
@@ -11,12 +11,6 @@ module Circuitry
11
11
  validate_setting(value, Publisher.async_strategies)
12
12
  super
13
13
  end
14
-
15
- def middleware
16
- @middleware ||= Middleware::Chain.new
17
- yield @middleware if block_given?
18
- @middleware
19
- end
20
14
  end
21
15
  end
22
16
  end
@@ -16,6 +16,12 @@ module Circuitry
16
16
  base.attribute :async_strategy, Symbol, default: ->(_page, _att) { :fork }
17
17
  end
18
18
 
19
+ def middleware
20
+ @middleware ||= Middleware::Chain.new
21
+ yield @middleware if block_given?
22
+ @middleware
23
+ end
24
+
19
25
  def aws_options
20
26
  {
21
27
  access_key_id: access_key,
@@ -1,6 +1,5 @@
1
1
  require 'virtus'
2
2
  require 'circuitry/config/shared_settings'
3
- require 'circuitry/middleware/entries/flush'
4
3
 
5
4
  module Circuitry
6
5
  module Config
@@ -28,16 +27,6 @@ module Circuitry
28
27
  raise ConfigError, "invalid lock strategy \"#{value.inspect}\""
29
28
  end
30
29
  end
31
-
32
- def middleware
33
- @middleware ||= Middleware::Chain.new do |middleware|
34
- middleware.add Middleware::Entries::Flush
35
- end
36
-
37
- yield @middleware if block_given?
38
-
39
- @middleware
40
- end
41
30
  end
42
31
  end
43
32
  end
@@ -1,3 +1,4 @@
1
+ require 'circuitry'
1
2
  require 'circuitry/provisioning/queue_creator'
2
3
  require 'circuitry/provisioning/topic_creator'
3
4
  require 'circuitry/provisioning/subscription_creator'
@@ -25,11 +25,11 @@ module Circuitry
25
25
  end
26
26
 
27
27
  def create_queue
28
- @_queue ||= Queue.new(create_primary_queue_internal)
28
+ @queue ||= Queue.new(create_primary_queue_internal)
29
29
  end
30
30
 
31
31
  def create_dead_letter_queue(name, max_receive_count)
32
- @_dl_queue ||= Queue.new(create_dl_queue_internal(name, max_receive_count))
32
+ @dl_queue ||= Queue.new(create_dl_queue_internal(name, max_receive_count))
33
33
  end
34
34
 
35
35
  private
@@ -26,10 +26,10 @@ module Circuitry
26
26
  topics.each do |topic|
27
27
  sns.subscribe(topic_arn: topic.arn, endpoint: queue.arn, protocol: 'sqs')
28
28
  end
29
- sqs.set_queue_attributes(
30
- queue_url: queue.url,
31
- attributes: build_policy
32
- )
29
+
30
+ if topics.any?
31
+ sqs.set_queue_attributes(queue_url: queue.url, attributes: build_policy)
32
+ end
33
33
  end
34
34
 
35
35
  private
@@ -17,10 +17,10 @@ module Circuitry
17
17
  end
18
18
 
19
19
  def topic
20
- return @_topic if defined?(@_topic)
20
+ return @topic if defined?(@topic)
21
21
 
22
22
  response = sns.create_topic(name: topic_name)
23
- @_topic = Topic.new(response.topic_arn)
23
+ @topic = Topic.new(response.topic_arn)
24
24
  end
25
25
 
26
26
  private
@@ -16,7 +16,8 @@ module Circuitry
16
16
  }.freeze
17
17
 
18
18
  CONNECTION_ERRORS = [
19
- Seahorse::Client::NetworkingError
19
+ ::Seahorse::Client::NetworkingError,
20
+ ::Aws::SNS::Errors::InternalFailure
20
21
  ].freeze
21
22
 
22
23
  attr_reader :timeout
@@ -59,7 +60,7 @@ module Circuitry
59
60
  logger.warn("Error publishing attempt ##{attempt_number}: #{error.class} (#{error.message}); retrying...")
60
61
  end
61
62
 
62
- with_retries(max_tries: 3, handler: handler, rescue: CONNECTION_ERRORS, base_sleep_seconds: 0, max_sleep_seconds: 0) do
63
+ with_retries(max_tries: 3, handler: handler, rescue: CONNECTION_ERRORS, base_sleep_seconds: 0.05, max_sleep_seconds: 0.25) do
63
64
  topic = Topic.find(topic_name)
64
65
  sns.publish(topic_arn: topic.arn, message: message)
65
66
  end
@@ -108,6 +108,7 @@ module Circuitry
108
108
 
109
109
  poller.poll(max_number_of_messages: batch_size, wait_time_seconds: wait_time, skip_delete: true) do |messages|
110
110
  process_messages(Array(messages), &block)
111
+ Circuitry.flush
111
112
  end
112
113
  end
113
114
 
@@ -1,6 +1,7 @@
1
1
  namespace :circuitry do
2
2
  desc 'Create subscriber queues and subscribe queue to topics'
3
- task setup: :environment do
3
+ task :setup do
4
+ require 'logger'
4
5
  require 'circuitry/provisioning'
5
6
 
6
7
  logger = Logger.new(STDOUT)
@@ -1,3 +1,3 @@
1
1
  module Circuitry
2
- VERSION = '3.1.3'
2
+ VERSION = '3.1.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circuitry
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.3
4
+ version: 3.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Huggins
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-03-23 00:00:00.000000000 Z
12
+ date: 2016-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '1.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: thor
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: bundler
58
72
  requirement: !ruby/object:Gem::Requirement
@@ -207,20 +221,6 @@ dependencies:
207
221
  - - "~>"
208
222
  - !ruby/object:Gem::Version
209
223
  version: '1.2'
210
- - !ruby/object:Gem::Dependency
211
- name: thor
212
- requirement: !ruby/object:Gem::Requirement
213
- requirements:
214
- - - ">="
215
- - !ruby/object:Gem::Version
216
- version: '0'
217
- type: :development
218
- prerelease: false
219
- version_requirements: !ruby/object:Gem::Requirement
220
- requirements:
221
- - - ">="
222
- - !ruby/object:Gem::Version
223
- version: '0'
224
224
  description: A Circuitry publisher application can broadcast events which can be processed
225
225
  independently by Circuitry subscriber applications.
226
226
  email:
@@ -258,7 +258,6 @@ files:
258
258
  - lib/circuitry/locks/redis.rb
259
259
  - lib/circuitry/message.rb
260
260
  - lib/circuitry/middleware/chain.rb
261
- - lib/circuitry/middleware/entries/flush.rb
262
261
  - lib/circuitry/middleware/entry.rb
263
262
  - lib/circuitry/processor.rb
264
263
  - lib/circuitry/processors/batcher.rb
@@ -1,16 +0,0 @@
1
- module Circuitry
2
- module Middleware
3
- module Entries
4
- class Flush
5
- def initialize(_options = {})
6
- end
7
-
8
- def call(_topic, _message)
9
- yield
10
- ensure
11
- Circuitry.flush
12
- end
13
- end
14
- end
15
- end
16
- end