circuitry 3.1.3 → 3.1.4
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 +8 -0
- data/README.md +21 -12
- data/circuitry.gemspec +1 -1
- data/lib/circuitry.rb +8 -8
- data/lib/circuitry/config/publisher_settings.rb +0 -6
- data/lib/circuitry/config/shared_settings.rb +6 -0
- data/lib/circuitry/config/subscriber_settings.rb +0 -11
- data/lib/circuitry/provisioning/provisioner.rb +1 -0
- data/lib/circuitry/provisioning/queue_creator.rb +2 -2
- data/lib/circuitry/provisioning/subscription_creator.rb +4 -4
- data/lib/circuitry/provisioning/topic_creator.rb +2 -2
- data/lib/circuitry/publisher.rb +3 -2
- data/lib/circuitry/subscriber.rb +1 -0
- data/lib/circuitry/tasks.rb +2 -1
- data/lib/circuitry/version.rb +1 -1
- metadata +16 -17
- data/lib/circuitry/middleware/entries/flush.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99b3ddd979a6bea1d3a1dfaba8222705d54d0444
|
4
|
+
data.tar.gz: e6a6a65560048bb702b66f6c5ace6d04449470e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7771d7687a28ea226bcff384cfa30baebabbd780983e4bdb593abc377f128e09a2d72d6dacfa3f43615e5b48153f2433d97559cfd8d4a54175dd6993a96a9c4
|
7
|
+
data.tar.gz: eee566c00b1239c2e87d80dff6dbb04573b5cc9bf0c43f58c6b937410548763c8d82745dc4ae4a9c0d2957e378c2b6cd57c7791d006e1ecba6e39e3c20e0b127
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
##
|
10
|
+
## Features
|
11
11
|
|
12
|
-
|
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
|
data/circuitry.gemspec
CHANGED
@@ -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
|
data/lib/circuitry.rb
CHANGED
@@ -18,23 +18,23 @@ require 'circuitry/version'
|
|
18
18
|
module Circuitry
|
19
19
|
class << self
|
20
20
|
def subscriber_config
|
21
|
-
@
|
22
|
-
yield @
|
23
|
-
@
|
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
|
-
@
|
27
|
+
@sub_config = Config::SubscriberSettings.new(options)
|
28
28
|
end
|
29
29
|
|
30
30
|
def publisher_config
|
31
|
-
@
|
32
|
-
yield @
|
33
|
-
@
|
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
|
-
@
|
37
|
+
@pub_config = Config::PublisherSettings.new(options)
|
38
38
|
end
|
39
39
|
|
40
40
|
def publish(topic_name, object, options = {})
|
@@ -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
|
@@ -25,11 +25,11 @@ module Circuitry
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def create_queue
|
28
|
-
@
|
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
|
-
@
|
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
|
-
|
30
|
-
|
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 @
|
20
|
+
return @topic if defined?(@topic)
|
21
21
|
|
22
22
|
response = sns.create_topic(name: topic_name)
|
23
|
-
@
|
23
|
+
@topic = Topic.new(response.topic_arn)
|
24
24
|
end
|
25
25
|
|
26
26
|
private
|
data/lib/circuitry/publisher.rb
CHANGED
@@ -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
|
data/lib/circuitry/subscriber.rb
CHANGED
data/lib/circuitry/tasks.rb
CHANGED
data/lib/circuitry/version.rb
CHANGED
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.
|
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-
|
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
|