circuitry 3.0.1 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -8
- data/README.md +13 -3
- data/lib/circuitry/config/shared_settings.rb +1 -1
- data/lib/circuitry/middleware/chain.rb +4 -0
- data/lib/circuitry/processors/batcher.rb +3 -3
- data/lib/circuitry/provisioning/provisioner.rb +6 -3
- data/lib/circuitry/subscriber.rb +23 -22
- data/lib/circuitry/testing.rb +15 -0
- data/lib/circuitry/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95884450075da2bde6359a923037db59ddaee7f6
|
4
|
+
data.tar.gz: 7b56e6c314947463b2d95627ec622632a9fe60d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d9000bb3af034d32c012a6610c1f2a791b7f1af3192e276d9901075828ee0a2a8221d5dc5f01b10c18cd8bf5c92348b1d4fea54a738e4136b1f9b17546e22b1
|
7
|
+
data.tar.gz: 3a810f4b53a4eb4c4e5227e6e877fe69bcc2cef12a22c2205854782f1cf174670d84159224eabf310e482a68bffa80dfce5e40377f287076d8e66847689d8864
|
data/CHANGELOG.md
CHANGED
@@ -1,17 +1,27 @@
|
|
1
|
+
## Circuitry 3.1.1 (Mar 3, 2016)
|
2
|
+
|
3
|
+
* Removed flush middleware. *Matt Huggins*
|
4
|
+
|
5
|
+
## Circuitry 3.1.0 (Mar 2, 2016)
|
6
|
+
|
7
|
+
* Added test stubs. *Matt Huggins*
|
8
|
+
* Added flush middleware. *Matt Huggins*
|
9
|
+
* Updated provisioning to permit publisher-only configuration (no queue name). *Matt Huggins*
|
10
|
+
|
1
11
|
## Circuitry 3.0.1 (Feb 19, 2016)
|
2
12
|
|
3
|
-
* Reworded provisioner subscription creator message *Brandon Croft*
|
13
|
+
* Reworded provisioner subscription creator message. *Brandon Croft*
|
4
14
|
|
5
15
|
## Circuitry 3.0.0 (Feb 19, 2016)
|
6
16
|
|
7
|
-
* Added separate configuration for publisher/subscriber applications *Brandon Croft*
|
8
|
-
* Added YML config option *Brandon Croft*
|
9
|
-
* Added max_receive_count and visibility_timeout subscriber config options *Brandon Croft*
|
10
|
-
*
|
17
|
+
* Added separate configuration for publisher/subscriber applications. *Brandon Croft*
|
18
|
+
* Added YML config option. *Brandon Croft*
|
19
|
+
* Added `max_receive_count` and `visibility_timeout` subscriber config options. *Brandon Croft*
|
20
|
+
* Replaced `on_thread_exit` and `on_fork_exit` with `on_async_exit` config option. *Brandon Croft*
|
11
21
|
|
12
22
|
## Circuitry 2.1.1 (Jan 30, 2016)
|
13
23
|
|
14
|
-
* Fixed missing require in subscriber *Brandon Croft*
|
24
|
+
* Fixed missing require in subscriber. *Brandon Croft*
|
15
25
|
|
16
26
|
## Circuitry 2.1.0 (Jan 28, 2016)
|
17
27
|
|
@@ -19,8 +29,8 @@
|
|
19
29
|
|
20
30
|
## Circuitry 2.0.0 (Jan 28, 2016)
|
21
31
|
|
22
|
-
* Added subscriber_queue_name config. *Brandon Croft*
|
23
|
-
* Added publisher_topic_names config. *Brandon Croft*
|
32
|
+
* Added `subscriber_queue_name` config. *Brandon Croft*
|
33
|
+
* Added `publisher_topic_names` config. *Brandon Croft*
|
24
34
|
* Added CLI and rake provisioning of queues and topics as defined by config. *Brandon Croft*
|
25
35
|
* Removed the requirement to provide a SQS URL to the subscriber. *Brandon Croft*
|
26
36
|
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ A Circuitry publisher application can broadcast events which can be fanned out t
|
|
16
16
|
Add this line to your application's Gemfile:
|
17
17
|
|
18
18
|
```ruby
|
19
|
-
gem 'circuitry', '~>
|
19
|
+
gem 'circuitry', '~> 3.1'
|
20
20
|
```
|
21
21
|
|
22
22
|
And then execute:
|
@@ -86,8 +86,8 @@ development:
|
|
86
86
|
production:
|
87
87
|
publisher:
|
88
88
|
topic_names:
|
89
|
-
-
|
90
|
-
-
|
89
|
+
- production-appname-user-create
|
90
|
+
- production-appname-user-destroy
|
91
91
|
subscriber:
|
92
92
|
queue_name: "production-appname"
|
93
93
|
dead_letter_queue_name: "production-appname-failures"
|
@@ -555,6 +555,16 @@ your middleware:
|
|
555
555
|
* `#clear`: Removes all middleware classes from the chain.
|
556
556
|
* `middleware.clear`
|
557
557
|
|
558
|
+
## Testing
|
559
|
+
|
560
|
+
Circuitry provides a simple option for testing publishing and subscribing without actually hitting
|
561
|
+
Amazon services. Inside your test suite (e.g.: `spec_helper.rb`), just make sure you include the
|
562
|
+
following line:
|
563
|
+
|
564
|
+
```ruby
|
565
|
+
require 'circuitry/testing'
|
566
|
+
```
|
567
|
+
|
558
568
|
## Development
|
559
569
|
|
560
570
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
@@ -11,10 +11,8 @@ module Circuitry
|
|
11
11
|
|
12
12
|
def run
|
13
13
|
queue = create_queue
|
14
|
-
|
15
|
-
|
14
|
+
subscribe_topics(queue, create_topics(:subscriber, subscriber_config.topic_names)) if queue
|
16
15
|
create_topics(:publisher, publisher_config.topic_names)
|
17
|
-
subscribe_topics(queue, create_topics(:subscriber, subscriber_config.topic_names))
|
18
16
|
end
|
19
17
|
|
20
18
|
private
|
@@ -30,6 +28,11 @@ module Circuitry
|
|
30
28
|
end
|
31
29
|
|
32
30
|
def create_queue
|
31
|
+
if subscriber_config.queue_name.nil?
|
32
|
+
logger.info 'Skipping queue creation: queue_name is not configured'
|
33
|
+
return nil
|
34
|
+
end
|
35
|
+
|
33
36
|
safe_aws('Create queue') do
|
34
37
|
queue = QueueCreator.find_or_create(
|
35
38
|
subscriber_config.queue_name,
|
data/lib/circuitry/subscriber.rb
CHANGED
@@ -131,50 +131,51 @@ module Circuitry
|
|
131
131
|
message = Message.new(message)
|
132
132
|
|
133
133
|
logger.info("Processing message #{message.id}")
|
134
|
-
handle_message(message, &block)
|
135
|
-
delete_message(message)
|
136
|
-
rescue => e
|
137
|
-
logger.error("Error processing message #{message.id}: #{e}")
|
138
|
-
error_handler.call(e) if error_handler
|
139
|
-
end
|
140
134
|
|
141
|
-
def handle_message(message, &block)
|
142
135
|
handled = try_with_lock(message.id) do
|
143
|
-
|
144
|
-
handle_message_with_timeout(message, &block)
|
145
|
-
end
|
136
|
+
handle_message_with_middleware(message, &block)
|
146
137
|
end
|
147
138
|
|
148
139
|
logger.info("Ignoring duplicate message #{message.id}") unless handled
|
140
|
+
rescue => e
|
141
|
+
logger.error("Error processing message #{message.id}: #{e}")
|
142
|
+
error_handler.call(e) if error_handler
|
149
143
|
end
|
150
144
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
block.call(message.body, message.topic.name)
|
145
|
+
def handle_message_with_middleware(message, &block)
|
146
|
+
middleware.invoke(message.topic.name, message.body) do
|
147
|
+
handle_message(message, &block)
|
148
|
+
delete_message(message)
|
156
149
|
end
|
157
|
-
rescue => e
|
158
|
-
logger.error("Error handling message #{message.id}: #{e}")
|
159
|
-
raise e
|
160
150
|
end
|
161
151
|
|
162
|
-
def try_with_lock(
|
163
|
-
if lock.soft_lock(
|
152
|
+
def try_with_lock(id)
|
153
|
+
if lock.soft_lock(id)
|
164
154
|
begin
|
165
155
|
yield
|
166
156
|
rescue => e
|
167
|
-
lock.unlock(
|
157
|
+
lock.unlock(id)
|
168
158
|
raise e
|
169
159
|
end
|
170
160
|
|
171
|
-
lock.hard_lock(
|
161
|
+
lock.hard_lock(id)
|
172
162
|
true
|
173
163
|
else
|
174
164
|
false
|
175
165
|
end
|
176
166
|
end
|
177
167
|
|
168
|
+
# TODO: Don't use ruby timeout.
|
169
|
+
# http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/
|
170
|
+
def handle_message(message, &block)
|
171
|
+
Timeout.timeout(timeout) do
|
172
|
+
block.call(message.body, message.topic.name)
|
173
|
+
end
|
174
|
+
rescue => e
|
175
|
+
logger.error("Error handling message #{message.id}: #{e}")
|
176
|
+
raise e
|
177
|
+
end
|
178
|
+
|
178
179
|
def delete_message(message)
|
179
180
|
logger.info("Removing message #{message.id} from queue")
|
180
181
|
sqs.delete_message(queue_url: queue, receipt_handle: message.receipt_handle)
|
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.
|
4
|
+
version: 3.1.1
|
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-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -275,6 +275,7 @@ files:
|
|
275
275
|
- lib/circuitry/services/sqs.rb
|
276
276
|
- lib/circuitry/subscriber.rb
|
277
277
|
- lib/circuitry/tasks.rb
|
278
|
+
- lib/circuitry/testing.rb
|
278
279
|
- lib/circuitry/topic.rb
|
279
280
|
- lib/circuitry/version.rb
|
280
281
|
homepage: https://github.com/kapost/circuitry
|
@@ -297,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
298
|
version: '0'
|
298
299
|
requirements: []
|
299
300
|
rubyforge_project:
|
300
|
-
rubygems_version: 2.4.
|
301
|
+
rubygems_version: 2.4.8
|
301
302
|
signing_key:
|
302
303
|
specification_version: 4
|
303
304
|
summary: Decouple ruby applications using Amazon SNS fanout with SQS processing.
|