circuitry 1.4.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +16 -0
- data/CHANGELOG.md +7 -0
- data/README.md +88 -62
- data/bin/console +4 -4
- data/circuitry.gemspec +12 -11
- data/exe/circuitry +7 -0
- data/lib/circuitry.rb +5 -3
- data/lib/circuitry/cli.rb +70 -0
- data/lib/circuitry/concerns/async.rb +11 -6
- data/lib/circuitry/configuration.rb +16 -9
- data/lib/circuitry/provisioner.rb +59 -0
- data/lib/circuitry/publisher.rb +18 -16
- data/lib/circuitry/queue.rb +27 -0
- data/lib/circuitry/queue_creator.rb +50 -0
- data/lib/circuitry/railtie.rb +9 -0
- data/lib/circuitry/subscriber.rb +56 -37
- data/lib/circuitry/subscription_creator.rb +60 -0
- data/lib/circuitry/tasks.rb +11 -0
- data/lib/circuitry/topic_creator.rb +2 -2
- data/lib/circuitry/version.rb +1 -1
- metadata +72 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d3f37801853268fc7adb65ff0f4d4c763f0f098
|
4
|
+
data.tar.gz: aae27a8ce4d592ff7e817c0aee62e2c82a973026
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdd6ebe7c82eec7d98dafbfad50cd056c554db06a9fbd4f41d749c3ed94bfa18efafbd693404ca3863804e007fa941807acee55376db52dbba2e0abb99457d5a
|
7
|
+
data.tar.gz: 01b6255d1c8d3826650cb4d7a263b71c28d310e7a69fb207b1e322495741531e36b21bd5d263f5702665a328077b6c7a5d19f3a4d6ca872d3162bf170d3f5ed7
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Style/HashSyntax:
|
2
|
+
EnforcedStyle: ruby19
|
3
|
+
Style/Documentation:
|
4
|
+
Enabled: false
|
5
|
+
Metrics/LineLength:
|
6
|
+
Max: 100
|
7
|
+
Style/SignalException:
|
8
|
+
Enabled: false
|
9
|
+
Style/BlockDelimiters:
|
10
|
+
Enabled: false
|
11
|
+
PercentLiteralDelimiters:
|
12
|
+
PreferredDelimiters:
|
13
|
+
'%w': []
|
14
|
+
'%W': []
|
15
|
+
'%i': []
|
16
|
+
'%I': []
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## Circuitry 2.0.0 (Jan 27, 2016)
|
2
|
+
|
3
|
+
* Added subscriber_queue_name config *Brandon Croft*
|
4
|
+
* Added publisher_topic_names config *Brandon Croft*
|
5
|
+
* Added CLI and rake provisioning of queues and topics as defined by config *Brandon Croft*
|
6
|
+
* Removed the requirement to provide a SQS URL to the subscriber *Brandon Croft*
|
7
|
+
|
1
8
|
## Circuitry 1.4.1 (Jan 21, 2016)
|
2
9
|
|
3
10
|
* Added publisher logging. *Matt Huggins*
|
data/README.md
CHANGED
@@ -1,17 +1,21 @@
|
|
1
1
|
# Circuitry
|
2
2
|
|
3
|
-
|
4
|
-
[SNS](http://aws.amazon.com/sns/) & [SQS](http://aws.amazon.com/sqs/).
|
3
|
+
[![Code Climate](https://codeclimate.com/repos/55720235e30ba0148f003033/badges/697cd6b997cc25e808f3/gpa.svg)](https://codeclimate.com/repos/55720235e30ba0148f003033/feed) [![Test Coverage](https://codeclimate.com/repos/55720235e30ba0148f003033/badges/697cd6b997cc25e808f3/coverage.svg)](https://codeclimate.com/repos/55720235e30ba0148f003033/coverage)
|
5
4
|
|
6
|
-
[
|
7
|
-
|
5
|
+
Decouple ruby applications using [SNS](http://aws.amazon.com/sns/) fanout with [SQS](http://aws.amazon.com/sqs/) processing.
|
6
|
+
|
7
|
+
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.
|
8
|
+
|
9
|
+
## How is Circuitry different from Shoryuken?
|
10
|
+
|
11
|
+
[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.
|
8
12
|
|
9
13
|
## Installation
|
10
14
|
|
11
15
|
Add this line to your application's Gemfile:
|
12
16
|
|
13
17
|
```ruby
|
14
|
-
gem 'circuitry'
|
18
|
+
gem 'circuitry', '~>2.0.0'
|
15
19
|
```
|
16
20
|
|
17
21
|
And then execute:
|
@@ -47,48 +51,71 @@ end
|
|
47
51
|
Available configuration options include:
|
48
52
|
|
49
53
|
* `access_key`: The AWS access key ID that has access to SNS publishing and/or
|
50
|
-
SQS subscribing.
|
54
|
+
SQS subscribing. *(required)*
|
51
55
|
* `secret_key`: The AWS secret access key that has access to SNS publishing
|
52
|
-
and/or SQS subscribing.
|
56
|
+
and/or SQS subscribing. *(required)*
|
53
57
|
* `region`: The AWS region that your SNS and/or SQS account lives in.
|
54
58
|
*(optional, default: "us-east-1")*
|
55
59
|
* `logger`: The logger to use for informational output, warnings, and error
|
56
|
-
messages.
|
60
|
+
messages. *(optional, default: `Logger.new(STDOUT)`)*
|
57
61
|
* `error_handler`: An object that responds to `call` with two arguments: the
|
58
62
|
deserialized message contents and the topic name used when publishing to SNS.
|
59
63
|
*(optional, default: `nil`)*
|
60
64
|
* `lock_strategy` - The store used to ensure that no duplicate messages are
|
61
|
-
processed.
|
62
|
-
more details regarding this option.
|
65
|
+
processed. Please refer to the [Lock Strategies](#lock-strategies) section for
|
66
|
+
more details regarding this option. *(default: `Circuitry::Locks::Memory.new`)*
|
63
67
|
* `publish_async_strategy`: One of `:fork`, `:thread`, or `:batch` that
|
64
|
-
determines how asynchronous publish requests are processed.
|
68
|
+
determines how asynchronous publish requests are processed. *(optional,
|
65
69
|
default: `:fork`)*
|
66
70
|
* `:fork`: Forks a detached child process that immediately sends the request.
|
67
|
-
* `:thread`: Creates a new thread that immediately sends the request.
|
71
|
+
* `:thread`: Creates a new thread that immediately sends the request. Because
|
68
72
|
threads are not guaranteed to complete when the process exits, completion can
|
69
73
|
be ensured by calling `Circuitry.flush`.
|
70
|
-
* `:batch`: Stores the request in memory to be submitted later.
|
74
|
+
* `:batch`: Stores the request in memory to be submitted later. Batched
|
71
75
|
requests must be manually sent by calling `Circuitry.flush`.
|
72
76
|
* `subscribe_async_strategy`: One of `:fork` or `:thread` that determines how
|
73
|
-
asynchronous subscribe requests are processed.
|
77
|
+
asynchronous subscribe requests are processed. *(optional, default: `:fork`)*
|
74
78
|
* `:fork`: Forks a detached child process that immediately begins querying the
|
75
79
|
queue.
|
76
80
|
* `:thread`: Creates a new thread that immediately sends begins querying the
|
77
81
|
queue.
|
78
|
-
* `on_thread_exit`: An object that responds to `call`.
|
82
|
+
* `on_thread_exit`: An object that responds to `call`. This is useful for
|
79
83
|
managing shared resources such as database connections that require closing.
|
80
|
-
It is only called when implementing the `:thread` async strategy.
|
84
|
+
It is only called when implementing the `:thread` async strategy. *(optional,
|
81
85
|
default: `nil`)*
|
82
|
-
* `on_fork_exit`: An object that responds to `call`.
|
86
|
+
* `on_fork_exit`: An object that responds to `call`. This is useful for
|
83
87
|
managing shared resources such as database connections that require closing,
|
84
|
-
It is only called when implementing the `:fork` async strategy.
|
88
|
+
It is only called when implementing the `:fork` async strategy. *(optional,
|
85
89
|
default: `nil`)*
|
90
|
+
* `subscriber_queue_name`: The name of the SQS queue that your subscriber application
|
91
|
+
will listen to. This queue will be created or configured during `rake circuitry:setup`
|
92
|
+
*(optional, default: `nil`)*
|
93
|
+
* `subscriber_dead_letter_queue_name`: The name of the SQS dead letter queue that will be
|
94
|
+
used after all retries fail. This queue will be created and configured during `rake
|
95
|
+
circuitry:setup` *(optional, default: `<subscriber_queue_name>-failures`)*
|
96
|
+
* `publisher_topic_names`: An array of topic names that your publishing application will
|
97
|
+
publish on. This configuration is only used during provisioning via `rake circuitry:setup`
|
98
|
+
|
99
|
+
### Provisioning
|
100
|
+
|
101
|
+
You can automatically provision SQS queues, SNS topics, and the subscriptions between them using two methods: the circuitry CLI or the `rake circuitry:setup` task. The rake task will provision the subscriber queue and publishing topics that are configured within your application.
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
Circuitry.config do |c|
|
105
|
+
c.subscriber_queue_name = 'myapp-production-events'
|
106
|
+
c.publisher_topic_names = ['theirapp-production-stuff-created', 'theirapp-production-stuff-deleted']
|
107
|
+
end
|
108
|
+
```
|
109
|
+
|
110
|
+
When provisioning, a dead letter queue is also created using the name "<queue_name>-failures" and a redrive policy of 8 retries to that dead letter queue is configured. You can customize the dead letter queue name in your configuration.
|
111
|
+
|
112
|
+
Run `ruby bin/circuitry help provision` for help using CLI provisioning.
|
86
113
|
|
87
114
|
### Publishing
|
88
115
|
|
89
|
-
Publishing is done via the `Circuitry.publish` method.
|
116
|
+
Publishing is done via the `Circuitry.publish` method. It accepts a topic name
|
90
117
|
that represents the SNS topic along with any non-nil object, representing the
|
91
|
-
data to be serialized.
|
118
|
+
data to be serialized. Whatever object is called will have its `to_json` method
|
92
119
|
called for serialization.
|
93
120
|
|
94
121
|
```ruby
|
@@ -99,13 +126,13 @@ Circuitry.publish('any-topic-name', obj)
|
|
99
126
|
The `publish` method also accepts options that impact instantiation of the
|
100
127
|
`Publisher` object, which currently includes the following options.
|
101
128
|
|
102
|
-
* `:async` - Whether or not publishing should occur in the background.
|
103
|
-
one of `:fork`, `:thread`, `:batch`, `true`, or `false`.
|
104
|
-
the `publish_async_strategy` value from the gem configuration.
|
129
|
+
* `:async` - Whether or not publishing should occur in the background. Accepts
|
130
|
+
one of `:fork`, `:thread`, `:batch`, `true`, or `false`. Passing `true` uses
|
131
|
+
the `publish_async_strategy` value from the gem configuration. Please refer to
|
105
132
|
the [Asynchronous Support](#asynchronous-support) section for more details
|
106
|
-
regarding this option.
|
133
|
+
regarding this option. *(default: `false`)*
|
107
134
|
* `:timeout` - The maximum amount of time in seconds that publishing a message
|
108
|
-
will be attempted before giving up.
|
135
|
+
will be attempted before giving up. If the timeout is exceeded, an exception
|
109
136
|
will raised to be handled by your application or `error_handler`. *(default:
|
110
137
|
15)*
|
111
138
|
|
@@ -125,12 +152,11 @@ publisher.publish('my-topic-name', obj)
|
|
125
152
|
|
126
153
|
### Subscribing
|
127
154
|
|
128
|
-
Subscribing is done via the `Circuitry.subscribe` method.
|
129
|
-
URL and takes a block for processing each message. This method **indefinitely
|
155
|
+
Subscribing is done via the `Circuitry.subscribe` method. It accepts a block for processing each message. This method **indefinitely
|
130
156
|
blocks**, processing messages as they are enqueued.
|
131
157
|
|
132
158
|
```ruby
|
133
|
-
Circuitry.subscribe
|
159
|
+
Circuitry.subscribe do |message, topic_name|
|
134
160
|
puts "Received #{topic_name} message: #{message.inspect}"
|
135
161
|
end
|
136
162
|
```
|
@@ -140,23 +166,23 @@ The `subscribe` method also accepts options that impact instantiation of the
|
|
140
166
|
|
141
167
|
* `:lock` - The strategy used to ensure that no duplicate messages are processed.
|
142
168
|
Accepts `true`, `false`, or an instance of a class inheriting from
|
143
|
-
`Circuitry::Locks::Base`.
|
144
|
-
the gem configuration.
|
169
|
+
`Circuitry::Locks::Base`. Passing `true` uses the `lock_strategy` value from
|
170
|
+
the gem configuration. Passing `false` uses the [NOOP](#NOOP) strategy. Please
|
145
171
|
refer to the [Lock Strategies](#lock-strategies) section for more details
|
146
|
-
regarding this option.
|
147
|
-
* `:async` - Whether or not subscribing should occur in the background.
|
148
|
-
one of `:fork`, `:thread`, `true`, or `false`.
|
149
|
-
`subscribe_async_strategy` value from the gem configuration.
|
150
|
-
asynchronous value will cause messages to be handled concurrently.
|
172
|
+
regarding this option. *(default: `true`)*
|
173
|
+
* `:async` - Whether or not subscribing should occur in the background. Accepts
|
174
|
+
one of `:fork`, `:thread`, `true`, or `false`. Passing `true` uses the
|
175
|
+
`subscribe_async_strategy` value from the gem configuration. Passing an
|
176
|
+
asynchronous value will cause messages to be handled concurrently. Please
|
151
177
|
refer to the [Asynchronous Support](#asynchronous-support) section for more
|
152
|
-
details regarding this option.
|
178
|
+
details regarding this option. *(default: `false`)*
|
153
179
|
* `:timeout` - The maximum amount of time in seconds that processing a message
|
154
|
-
will be attempted before giving up.
|
155
|
-
will raised to be handled by your application or `error_handler`.
|
180
|
+
will be attempted before giving up. If the timeout is exceeded, an exception
|
181
|
+
will raised to be handled by your application or `error_handler`. *(default:
|
156
182
|
15)*
|
157
183
|
* `:wait_time` - The number of seconds to wait for messages while connected to
|
158
|
-
SQS.
|
159
|
-
short-polling.
|
184
|
+
SQS. Anything above 0 results in long-polling, while 0 results in
|
185
|
+
short-polling. *(default: 10)*
|
160
186
|
* `:batch_size` - The number of messages to retrieve in a single SQS request.
|
161
187
|
*(default: 10)*
|
162
188
|
|
@@ -193,7 +219,7 @@ batching) while subscribing supports two (forking and threading).
|
|
193
219
|
#### Forking
|
194
220
|
|
195
221
|
When forking a child process, that child is detached so that your application
|
196
|
-
does not need to worry about waiting for the process to finish.
|
222
|
+
does not need to worry about waiting for the process to finish. Forked requests
|
197
223
|
begin processing immediately and do not have any overhead in terms of waiting for
|
198
224
|
them to complete.
|
199
225
|
|
@@ -205,9 +231,9 @@ asynchronous support:
|
|
205
231
|
asynchronous strategy in such circumstances.
|
206
232
|
|
207
233
|
2. Forking results in resources being copied from the parent process to the child
|
208
|
-
process.
|
234
|
+
process. In order to prevent database connection errors and the like, you
|
209
235
|
should properly handle closing and reopening resources before and after
|
210
|
-
forking, respectively.
|
236
|
+
forking, respectively. For example, if you are using Rails with Unicorn, you
|
211
237
|
may need to add the following code to your `unicorn.rb` configuration:
|
212
238
|
|
213
239
|
before_fork do |server, worker|
|
@@ -229,14 +255,14 @@ asynchronous support:
|
|
229
255
|
|
230
256
|
#### Threading
|
231
257
|
|
232
|
-
Threaded publish and subscribe requests begin processing immediately.
|
258
|
+
Threaded publish and subscribe requests begin processing immediately. Unlike
|
233
259
|
forking, it's up to you to ensure that all threads complete before your
|
234
|
-
application exits.
|
260
|
+
application exits. This can be done by calling `Circuitry.flush`.
|
235
261
|
|
236
262
|
#### Batching
|
237
263
|
|
238
264
|
Batched publish and subscribe requests are queued in memory and do not begin
|
239
|
-
processing until you explicit flush them.
|
265
|
+
processing until you explicit flush them. This can be done by calling
|
240
266
|
`Circuitry.flush`.
|
241
267
|
|
242
268
|
### Lock Strategies
|
@@ -263,7 +289,7 @@ complete), while the hard lock has a default TTL of 24 hours (based upon
|
|
263
289
|
[a suggestion by an AWS employee](https://forums.aws.amazon.com/thread.jspa?threadID=140782#507605)).
|
264
290
|
The soft and hard TTL values can be changed by passing a `:soft_ttl` or
|
265
291
|
`:hard_ttl` value to the lock initializer, representing the number of seconds
|
266
|
-
that a lock should persist.
|
292
|
+
that a lock should persist. For example:
|
267
293
|
|
268
294
|
```ruby
|
269
295
|
Circuitry.config.lock_strategy = Circuitry::Locks::Memory.new(
|
@@ -275,8 +301,8 @@ Circuitry.config.lock_strategy = Circuitry::Locks::Memory.new(
|
|
275
301
|
#### Memory
|
276
302
|
|
277
303
|
If not specified in your circuitry configuration, the memory store will be used
|
278
|
-
by default.
|
279
|
-
that it has no third-party dependencies.
|
304
|
+
by default. This lock strategy is provided as the lowest barrier to entry given
|
305
|
+
that it has no third-party dependencies. It should be avoided if running
|
280
306
|
multiple subscriber processes or if expecting a high throughput that would result
|
281
307
|
in a large amount of memory consumption.
|
282
308
|
|
@@ -289,7 +315,7 @@ Circuitry::Locks::Memory.new
|
|
289
315
|
Using the redis lock strategy requires that you add `gem 'redis'` to your
|
290
316
|
`Gemfile`, as it is not included bundled with the circuitry gem by default.
|
291
317
|
|
292
|
-
There are two ways to use the redis lock strategy.
|
318
|
+
There are two ways to use the redis lock strategy. The first is to pass your
|
293
319
|
redis connection options to the lock in the same way that you would when building
|
294
320
|
a new `Redis` object.
|
295
321
|
|
@@ -299,7 +325,7 @@ Circuitry::Locks::Redis.new(url: 'redis://localhost:6379')
|
|
299
325
|
|
300
326
|
The second way is to pass in a `:client` option that specifies either the redis
|
301
327
|
client itself or a [ConnectionPool](https://github.com/mperham/connection_pool)
|
302
|
-
of redis clients.
|
328
|
+
of redis clients. This is useful for more advanced usage such as sharing an
|
303
329
|
existing redis connection, connection pooling, utilizing
|
304
330
|
[Redis::Namespace](https://github.com/resque/redis-namespace), or utilizing
|
305
331
|
[hiredis](https://github.com/redis/hiredis-rb).
|
@@ -317,9 +343,9 @@ Circuitry::Locks::Redis.new(client: client)
|
|
317
343
|
Using the memcache lock strategy requires that you add `gem 'dalli'` to your
|
318
344
|
`Gemfile`, as it is not included bundled with the circuitry gem by default.
|
319
345
|
|
320
|
-
There are two ways to use the memcache lock strategy.
|
346
|
+
There are two ways to use the memcache lock strategy. The first is to pass your
|
321
347
|
dalli connection host and options to the lock in the same way that you would when
|
322
|
-
building a new `Dalli::Client` object.
|
348
|
+
building a new `Dalli::Client` object. The special `host` option will be treated
|
323
349
|
as the memcache host, just as the first argument to `Dalli::Client`.
|
324
350
|
|
325
351
|
```ruby
|
@@ -327,7 +353,7 @@ Circuitry::Locks::Memcache.new(host: 'localhost:11211', namespace: '...')
|
|
327
353
|
```
|
328
354
|
|
329
355
|
The second way is to pass in a `:client` option that specifies the dalli client
|
330
|
-
itself.
|
356
|
+
itself. This is useful for sharing an existing memcache connection.
|
331
357
|
|
332
358
|
```ruby
|
333
359
|
client = Dalli::Client.new('localhost:11211', namespace: '...')
|
@@ -338,23 +364,23 @@ Circuitry::Locks::Memcache.new(client: client)
|
|
338
364
|
|
339
365
|
Using the noop lock strategy permits you to continue to treat SQS as a
|
340
366
|
distributed queue in a true sense, meaning that you might receive duplicate
|
341
|
-
messages.
|
367
|
+
messages. Please refer to the Amazon SQS documentation pertaining to the
|
342
368
|
[Properties of Distributed Queues](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/DistributedQueues.html).
|
343
369
|
|
344
370
|
#### Custom
|
345
371
|
|
346
|
-
It's also possible to roll your own lock strategy.
|
372
|
+
It's also possible to roll your own lock strategy. Simply create a class that
|
347
373
|
includes (or module that extends) `Circuitry::Locks::Base` and implements the
|
348
374
|
following methods:
|
349
375
|
|
350
|
-
* `lock`: Accepts the `key` and `ttl` as parameters.
|
351
|
-
locked, this method must return false.
|
352
|
-
must lock the key for `ttl` seconds and return true.
|
376
|
+
* `lock`: Accepts the `key` and `ttl` as parameters. If the key is already
|
377
|
+
locked, this method must return false. If the key is not already locked, it
|
378
|
+
must lock the key for `ttl` seconds and return true. It is important that
|
353
379
|
the check and update are **atomic** in order to ensure the same message isn't
|
354
380
|
processed more than once.
|
355
|
-
* `lock!`: Accepts the `key` and `ttl` as parameters.
|
381
|
+
* `lock!`: Accepts the `key` and `ttl` as parameters. Must lock the key for
|
356
382
|
`ttl` seconds regardless of whether or not the key was previously locked.
|
357
|
-
* `unlock!`: Accepts the `key` as a parameter.
|
383
|
+
* `unlock!`: Accepts the `key` as a parameter. Must unlock (delete) the key if
|
358
384
|
it was previously locked.
|
359
385
|
|
360
386
|
For example, a database-backed solution might look something like the following:
|
@@ -408,7 +434,7 @@ and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
408
434
|
|
409
435
|
## Contributing
|
410
436
|
|
411
|
-
1. Fork it (
|
437
|
+
1. Fork it (https://github.com/kapost/circuitry/fork)
|
412
438
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
413
439
|
3. Update the changelog
|
414
440
|
4. Commit your changes (`git commit -am 'Add some feature'`)
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'circuitry'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require
|
10
|
+
# require 'pry'
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
data/circuitry.gemspec
CHANGED
@@ -6,11 +6,11 @@ require 'circuitry/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'circuitry'
|
8
8
|
spec.version = Circuitry::VERSION
|
9
|
-
spec.authors = ['Matt Huggins']
|
10
|
-
spec.email = ['matt.huggins@kapost.com']
|
9
|
+
spec.authors = ['Matt Huggins', 'Brandon Croft']
|
10
|
+
spec.email = ['matt.huggins@kapost.com', 'brandon@kapost.com']
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{
|
12
|
+
spec.summary = %q{Decouple ruby applications using Amazon SNS fanout with SQS processing.}
|
13
|
+
spec.description = %q{A Circuitry publisher application can broadcast events which can be processed independently by Circuitry subscriber applications.}
|
14
14
|
spec.homepage = 'https://github.com/kapost/circuitry'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
@@ -23,15 +23,16 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency 'retries', '~> 0.0.5'
|
24
24
|
spec.add_dependency 'virtus', '~> 1.0'
|
25
25
|
|
26
|
-
spec.add_development_dependency 'pry-byebug'
|
27
26
|
spec.add_development_dependency 'bundler', '~> 1.8'
|
28
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
-
spec.add_development_dependency 'rspec', '~> 3.2'
|
30
|
-
spec.add_development_dependency 'rspec-its', '~> 1.2'
|
31
27
|
spec.add_development_dependency 'codeclimate-test-reporter'
|
32
|
-
spec.add_development_dependency '
|
33
|
-
spec.add_development_dependency 'mock_redis'
|
28
|
+
spec.add_development_dependency 'connection_pool'
|
34
29
|
spec.add_development_dependency 'dalli'
|
35
30
|
spec.add_development_dependency 'memcache_mock'
|
36
|
-
spec.add_development_dependency '
|
31
|
+
spec.add_development_dependency 'mock_redis'
|
32
|
+
spec.add_development_dependency 'pry-byebug'
|
33
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
+
spec.add_development_dependency 'redis'
|
35
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
36
|
+
spec.add_development_dependency 'rspec-its', '~> 1.2'
|
37
|
+
spec.add_development_dependency 'thor'
|
37
38
|
end
|
data/exe/circuitry
ADDED
data/lib/circuitry.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require 'circuitry/
|
1
|
+
require 'circuitry/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
|
2
|
+
require 'circuitry/configuration'
|
2
3
|
require 'circuitry/locks/base'
|
3
4
|
require 'circuitry/locks/memcache'
|
4
5
|
require 'circuitry/locks/memory'
|
@@ -11,6 +12,7 @@ require 'circuitry/processors/threader'
|
|
11
12
|
require 'circuitry/configuration'
|
12
13
|
require 'circuitry/publisher'
|
13
14
|
require 'circuitry/subscriber'
|
15
|
+
require 'circuitry/version'
|
14
16
|
|
15
17
|
module Circuitry
|
16
18
|
def self.config(&block)
|
@@ -23,8 +25,8 @@ module Circuitry
|
|
23
25
|
Publisher.new(options).publish(topic_name, object)
|
24
26
|
end
|
25
27
|
|
26
|
-
def self.subscribe(
|
27
|
-
Subscriber.new(
|
28
|
+
def self.subscribe(options = {}, &block)
|
29
|
+
Subscriber.new(options).subscribe(&block)
|
28
30
|
end
|
29
31
|
|
30
32
|
def self.flush
|