circuitry 2.1.1 → 3.0.0
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 +7 -0
- data/README.md +107 -59
- data/circuitry.gemspec +2 -2
- data/lib/circuitry.rb +32 -15
- data/lib/circuitry/cli.rb +32 -32
- data/lib/circuitry/config/file_loader.rb +24 -0
- data/lib/circuitry/config/publisher_settings.rb +16 -0
- data/lib/circuitry/config/shared_settings.rb +39 -0
- data/lib/circuitry/config/subscriber_settings.rb +32 -0
- data/lib/circuitry/locks/base.rb +3 -3
- data/lib/circuitry/locks/memory.rb +4 -4
- data/lib/circuitry/locks/noop.rb +1 -1
- data/lib/circuitry/locks/redis.rb +1 -1
- data/lib/circuitry/middleware/chain.rb +1 -1
- data/lib/circuitry/processor.rb +12 -10
- data/lib/circuitry/processors/forker.rb +1 -1
- data/lib/circuitry/processors/threader.rb +1 -1
- data/lib/circuitry/provisioning.rb +9 -0
- data/lib/circuitry/provisioning/provisioner.rb +71 -0
- data/lib/circuitry/provisioning/queue_creator.rb +64 -0
- data/lib/circuitry/provisioning/subscription_creator.rb +65 -0
- data/lib/circuitry/provisioning/topic_creator.rb +31 -0
- data/lib/circuitry/publisher.rb +5 -6
- data/lib/circuitry/queue.rb +25 -3
- data/lib/circuitry/railtie.rb +9 -0
- data/lib/circuitry/services/sns.rb +1 -1
- data/lib/circuitry/services/sqs.rb +1 -1
- data/lib/circuitry/subscriber.rb +8 -8
- data/lib/circuitry/tasks.rb +3 -3
- data/lib/circuitry/topic.rb +24 -2
- data/lib/circuitry/version.rb +1 -1
- metadata +11 -7
- data/lib/circuitry/configuration.rb +0 -64
- data/lib/circuitry/provisioner.rb +0 -60
- data/lib/circuitry/queue_creator.rb +0 -50
- data/lib/circuitry/subscription_creator.rb +0 -60
- data/lib/circuitry/topic_creator.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df4dbe3ed4201727d1176f9fe8a520ec273b70e6
|
4
|
+
data.tar.gz: ee091c7d8112aa937040c5bb9dbfb3b4979094ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 963e72ac4514a4d5eaa65eff1a745bbb8c4fce67cb8d244e9287bdc9b5017d17eeb8b97a24555ae4be3764c880052320c9aa219f395af7ba88bdbcae5a35e3df
|
7
|
+
data.tar.gz: 5e42c1e6858ca016b19dc6c1f954547672e20ff9857d06d58747aa05f4266e84c46eb1c9f45159b12102ef7664cc6fa2ed12787440835c60fb9c2c67521622d6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## Circuitry 3.0.0 (Feb 19, 2016)
|
2
|
+
|
3
|
+
* Added separate configuration for publisher/subscriber applications *Brandon Croft*
|
4
|
+
* Added YML config option *Brandon Croft*
|
5
|
+
* Added max_receive_count and visibility_timeout subscriber config options *Brandon Croft*
|
6
|
+
* Replace on_thread_exit and on_fork_exit with on_async_exit config option *Brandon Croft*
|
7
|
+
|
1
8
|
## Circuitry 2.1.1 (Jan 30, 2016)
|
2
9
|
|
3
10
|
* Fixed missing require in subscriber *Brandon Croft*
|
data/README.md
CHANGED
@@ -29,10 +29,13 @@ Or install it yourself as:
|
|
29
29
|
|
30
30
|
## Usage
|
31
31
|
|
32
|
-
Circuitry is configured via its configuration object.
|
32
|
+
Circuitry is configured via its configuration object or via circuitry.yml config.
|
33
33
|
|
34
34
|
```ruby
|
35
|
-
Circuitry.
|
35
|
+
Circuitry.subscriber_config do |c|
|
36
|
+
c.queue_name = "#{Rails.env}-appname"
|
37
|
+
c.dead_letter_queue_name = "#{Rails.env}-appname-failures"
|
38
|
+
c.max_receive_count = 8
|
36
39
|
c.access_key = 'YOUR_AWS_ACCESS_KEY'
|
37
40
|
c.secret_key = 'YOUR_AWS_SECRET_KEY'
|
38
41
|
c.region = 'us-east-1'
|
@@ -42,14 +45,58 @@ Circuitry.config do |c|
|
|
42
45
|
HoneyBadger.flush
|
43
46
|
end
|
44
47
|
c.lock_strategy = Circuitry::Locks::Redis.new(url: 'redis://localhost:6379')
|
45
|
-
c.
|
46
|
-
c.
|
47
|
-
|
48
|
-
|
48
|
+
c.async_strategy = :thread
|
49
|
+
c.on_async_exit = proc { Mongoid.disconnect_sessions }
|
50
|
+
end
|
51
|
+
|
52
|
+
Circuitry.publisher_config do |c|
|
53
|
+
c.access_key = 'YOUR_AWS_ACCESS_KEY'
|
54
|
+
c.secret_key = 'YOUR_AWS_SECRET_KEY'
|
55
|
+
c.region = 'us-east-1'
|
56
|
+
c.logger = Rails.logger
|
57
|
+
c.error_handler = proc do |error|
|
58
|
+
HoneyBadger.notify(error)
|
59
|
+
HoneyBadger.flush
|
60
|
+
end
|
61
|
+
c.async_strategy = :batch
|
49
62
|
end
|
50
63
|
```
|
51
64
|
|
52
|
-
|
65
|
+
Many of the advanced options, such as `error_handler` or `async_strategy` require this initializer-
|
66
|
+
style configuration. A simpler option is available via config/circuitry.yml
|
67
|
+
(or config/circuitry.yml.erb):
|
68
|
+
|
69
|
+
```yml
|
70
|
+
---
|
71
|
+
access_key: "YOUR_AWS_ACCESS_KEY"
|
72
|
+
secret_key: "YOUR_AWS_SECRET_KEY"
|
73
|
+
region: "us-east-1"
|
74
|
+
|
75
|
+
development:
|
76
|
+
publisher:
|
77
|
+
topic_names:
|
78
|
+
- brandonc-appname-user-create
|
79
|
+
- brandonc-appname-user-destroy
|
80
|
+
subscriber:
|
81
|
+
queue_name: "brandonc-appname"
|
82
|
+
dead_letter_queue_name: "brandonc-appname-failures"
|
83
|
+
topic_names:
|
84
|
+
- brandonc-otherapp-content-create
|
85
|
+
- brandonc-otherapp-content-destroy
|
86
|
+
production:
|
87
|
+
publisher:
|
88
|
+
topic_names:
|
89
|
+
- brandonc-appname-user-create
|
90
|
+
- brandonc-appname-user-destroy
|
91
|
+
subscriber:
|
92
|
+
queue_name: "production-appname"
|
93
|
+
dead_letter_queue_name: "production-appname-failures"
|
94
|
+
topic_names:
|
95
|
+
- production-otherapp-content-create
|
96
|
+
- production-otherapp-content-destroy
|
97
|
+
```
|
98
|
+
|
99
|
+
Available configuration options for *both* subscriber and publisher applications include:
|
53
100
|
|
54
101
|
* `access_key`: The AWS access key ID that has access to SNS publishing and/or
|
55
102
|
SQS subscribing. *(required)*
|
@@ -62,10 +109,7 @@ Available configuration options include:
|
|
62
109
|
* `error_handler`: An object that responds to `call` with two arguments: the
|
63
110
|
deserialized message contents and the topic name used when publishing to SNS.
|
64
111
|
*(optional, default: `nil`)*
|
65
|
-
* `
|
66
|
-
processed. Please refer to the [Lock Strategies](#lock-strategies) section for
|
67
|
-
more details regarding this option. *(default: `Circuitry::Locks::Memory.new`)*
|
68
|
-
* `publish_async_strategy`: One of `:fork`, `:thread`, or `:batch` that
|
112
|
+
* `async_strategy`: One of `:fork`, `:thread`, or `:batch` that
|
69
113
|
determines how asynchronous publish requests are processed. *(optional,
|
70
114
|
default: `:fork`)*
|
71
115
|
* `:fork`: Forks a detached child process that immediately sends the request.
|
@@ -73,36 +117,36 @@ Available configuration options include:
|
|
73
117
|
threads are not guaranteed to complete when the process exits, completion can
|
74
118
|
be ensured by calling `Circuitry.flush`.
|
75
119
|
* `:batch`: Stores the request in memory to be submitted later. Batched
|
76
|
-
requests must be manually sent by calling `Circuitry.flush`.
|
77
|
-
|
78
|
-
|
79
|
-
* `:fork`: Forks a detached child process that immediately begins querying the
|
80
|
-
queue.
|
81
|
-
* `:thread`: Creates a new thread that immediately sends begins querying the
|
82
|
-
queue.
|
83
|
-
* `on_thread_exit`: An object that responds to `call`. This is useful for
|
120
|
+
requests must be manually sent by calling `Circuitry.flush`. Only valid as a
|
121
|
+
publishing strategy
|
122
|
+
* `on_async_exit`: An object that responds to `call`. This is useful for
|
84
123
|
managing shared resources such as database connections that require closing.
|
85
|
-
It is only called when implementing the `:thread` async strategy. *(optional,
|
86
|
-
default: `nil`)*
|
87
|
-
* `on_fork_exit`: An object that responds to `call`. This is useful for
|
88
|
-
managing shared resources such as database connections that require closing,
|
89
|
-
It is only called when implementing the `:fork` async strategy. *(optional,
|
90
|
-
default: `nil`)*
|
91
|
-
* `publisher_topic_names`: An array of topic names that your publishing application will
|
92
|
-
publish on. This configuration is only used during provisioning via `rake circuitry:setup`
|
93
|
-
* `subscriber_queue_name`: The name of the SQS queue that your subscriber application
|
94
|
-
will listen to. This queue will be created or configured during `rake circuitry:setup`
|
95
124
|
*(optional, default: `nil`)*
|
96
|
-
* `
|
97
|
-
|
98
|
-
|
99
|
-
* `publisher_middleware`: A chain of middleware that sent messages must go through.
|
100
|
-
Please refer to the [Middleware](#middleware) section for more details regarding this
|
101
|
-
option.
|
102
|
-
* `subscriber_middleware`: A chain of middleware that received messages must go through.
|
125
|
+
* `topic_names`: An array of topic names that your application will
|
126
|
+
publish and/or subscribe to. This configuration is only used during provisioning.
|
127
|
+
* `middleware`: A chain of middleware that messages must go through when sent or received.
|
103
128
|
Please refer to the [Middleware](#middleware) section for more details regarding this
|
104
129
|
option.
|
105
130
|
|
131
|
+
Available configuration options for subscriber applications include:
|
132
|
+
|
133
|
+
* `queue_name`: The name of the SQS queue that your subscriber application
|
134
|
+
will listen to. This queue will be created or configured during provisioning.
|
135
|
+
* `dead_letter_queue_name`: The name of the SQS dead letter queue that will be
|
136
|
+
used after all retries fail. This configuration value is only used during provisioning.
|
137
|
+
*(optional, default: `<subscriber_queue_name>-failures`)*
|
138
|
+
* `lock_strategy` - The store used to ensure that no duplicate messages are
|
139
|
+
processed. Please refer to the [Lock Strategies](#lock-strategies) section for
|
140
|
+
more details regarding this option. *(default: `Circuitry::Locks::Memory.new`)*
|
141
|
+
* `max_receive_count` - The number of times a message will be received by the queue after
|
142
|
+
unsuccessful attempts to process it before it is discarded or added to the
|
143
|
+
`dead_letter_queue_name` queue. This configuration value is only used during
|
144
|
+
provisioning. *(optional, default: 8)*
|
145
|
+
* `visibility_timeout` - A period of time during which Amazon SQS prevents other subscribers from
|
146
|
+
receiving and processing that message (before it is deleted by circuitry after being processed
|
147
|
+
successfully.) This configuration value is only used during provisioning.
|
148
|
+
*(optional, default: 1800)*
|
149
|
+
|
106
150
|
### Provisioning
|
107
151
|
|
108
152
|
You can automatically provision SQS queues, SNS topics, and the subscriptions between them using
|
@@ -110,17 +154,16 @@ two methods: the circuitry CLI or the `rake circuitry:setup` task. The rake task
|
|
110
154
|
subscriber queue and publishing topics that are configured within your application.
|
111
155
|
|
112
156
|
```ruby
|
113
|
-
Circuitry.
|
114
|
-
c.
|
115
|
-
c.
|
157
|
+
Circuitry.subscriber_config do |c|
|
158
|
+
c.queue_name = 'myapp-production-events'
|
159
|
+
c.topic_names = ['theirapp-production-stuff-created', 'theirapp-production-stuff-deleted']
|
116
160
|
end
|
117
161
|
```
|
118
162
|
|
119
|
-
When provisioning, a dead letter queue is also created using the name "<queue_name>-failures"
|
120
|
-
|
121
|
-
letter queue name in your configuration.
|
163
|
+
When provisioning, a dead letter queue is also created using the name "<queue_name>-failures". You
|
164
|
+
can customize the dead letter queue name in your configuration.
|
122
165
|
|
123
|
-
Run `
|
166
|
+
Run `circuitry help provision` for help using CLI provisioning.
|
124
167
|
|
125
168
|
### Publishing
|
126
169
|
|
@@ -139,7 +182,7 @@ The `publish` method also accepts options that impact instantiation of the
|
|
139
182
|
|
140
183
|
* `:async` - Whether or not publishing should occur in the background. Accepts
|
141
184
|
one of `:fork`, `:thread`, `:batch`, `true`, or `false`. Passing `true` uses
|
142
|
-
the `
|
185
|
+
the `async_strategy` value from the gem configuration. Please refer to
|
143
186
|
the [Asynchronous Support](#asynchronous-support) section for more details
|
144
187
|
regarding this option. *(default: `false`)*
|
145
188
|
* `:timeout` - The maximum amount of time in seconds that publishing a message
|
@@ -183,7 +226,7 @@ The `subscribe` method also accepts options that impact instantiation of the
|
|
183
226
|
regarding this option. *(default: `true`)*
|
184
227
|
* `:async` - Whether or not subscribing should occur in the background. Accepts
|
185
228
|
one of `:fork`, `:thread`, `true`, or `false`. Passing `true` uses the
|
186
|
-
`
|
229
|
+
`async_strategy` value from the gem configuration. Passing an
|
187
230
|
asynchronous value will cause messages to be handled concurrently. Please
|
188
231
|
refer to the [Asynchronous Support](#asynchronous-support) section for more
|
189
232
|
details regarding this option. *(default: `false`)*
|
@@ -206,7 +249,7 @@ options = {
|
|
206
249
|
batch_size: 20
|
207
250
|
}
|
208
251
|
|
209
|
-
Circuitry.subscribe(
|
252
|
+
Circuitry.subscribe(options) do |message, topic_name|
|
210
253
|
# ...
|
211
254
|
end
|
212
255
|
```
|
@@ -217,7 +260,7 @@ Alternatively, if your options hash will remain unchanged, you can build a singl
|
|
217
260
|
```ruby
|
218
261
|
options = { ... }
|
219
262
|
subscriber = Circuitry::Subscriber.new(options)
|
220
|
-
subscriber.subscribe
|
263
|
+
subscriber.subscribe do |message, topic_name|
|
221
264
|
# ...
|
222
265
|
end
|
223
266
|
```
|
@@ -303,7 +346,7 @@ The soft and hard TTL values can be changed by passing a `:soft_ttl` or
|
|
303
346
|
that a lock should persist. For example:
|
304
347
|
|
305
348
|
```ruby
|
306
|
-
Circuitry.
|
349
|
+
Circuitry.subscriber_config.lock_strategy = Circuitry::Locks::Memory.new(
|
307
350
|
soft_ttl: 10 * 60, # 10 minutes
|
308
351
|
hard_ttl: 48 * 60 * 60 # 48 hours
|
309
352
|
)
|
@@ -430,7 +473,7 @@ pass your lock instance to the configuration as the `:lock_strategy`.
|
|
430
473
|
|
431
474
|
```ruby
|
432
475
|
connection = PG.connect(...)
|
433
|
-
Circuitry.
|
476
|
+
Circuitry.subcriber_config.lock_strategy = DatabaseLockStrategy.new(connection: connection)
|
434
477
|
```
|
435
478
|
|
436
479
|
### Middleware
|
@@ -454,7 +497,7 @@ class LoggerMiddleware
|
|
454
497
|
self.namespace = namespace
|
455
498
|
self.logger = logger
|
456
499
|
end
|
457
|
-
|
500
|
+
|
458
501
|
def call(topic, message)
|
459
502
|
logger.info("#{namespace} (start): #{topic} - #{message}")
|
460
503
|
yield
|
@@ -471,24 +514,29 @@ end
|
|
471
514
|
Adding the middleware to the stack happens through the Circuitry config.
|
472
515
|
|
473
516
|
```ruby
|
474
|
-
Circuitry.
|
517
|
+
Circuitry.subscriber_config do |config|
|
475
518
|
# single-line format
|
476
|
-
|
477
|
-
circuitry.subscriber_middleware.add LoggerMiddleware, namespace: 'subscriber', logger: Rails.logger
|
519
|
+
config.middleware.add LoggerMiddleware, namespace: 'subscriber_app', logger: Rails.logger
|
478
520
|
|
479
521
|
# block format
|
480
|
-
|
481
|
-
chain.add LoggerMiddleware, namespace: '
|
522
|
+
config.middleware do |chain|
|
523
|
+
chain.add LoggerMiddleware, namespace: 'subscriber_app', logger: Rails.logger
|
482
524
|
end
|
525
|
+
end
|
483
526
|
|
484
|
-
|
485
|
-
|
527
|
+
Circuitry.publisher_config do |config|
|
528
|
+
# single-line format
|
529
|
+
config.middleware.add LoggerMiddleware, namespace: 'publisher_app'
|
530
|
+
|
531
|
+
# block format
|
532
|
+
config.middleware do |chain|
|
533
|
+
chain.add LoggerMiddleware, namespace: 'publisher_app'
|
486
534
|
end
|
487
535
|
end
|
488
536
|
```
|
489
537
|
|
490
|
-
|
491
|
-
|
538
|
+
`config.middleware` responds to a handful of methods that can be used for configuring
|
539
|
+
your middleware:
|
492
540
|
|
493
541
|
* `#add`: Appends a middleware class to the end of the chain. If the class already exists, it is
|
494
542
|
replaced.
|
data/circuitry.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Matt Huggins', 'Brandon Croft']
|
10
10
|
spec.email = ['matt.huggins@kapost.com', 'brandon@kapost.com']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
12
|
+
spec.summary = 'Decouple ruby applications using Amazon SNS fanout with SQS processing.'
|
13
|
+
spec.description = '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
|
|
data/lib/circuitry.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'circuitry/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
|
2
|
-
require 'circuitry/
|
2
|
+
require 'circuitry/config/publisher_settings'
|
3
|
+
require 'circuitry/config/subscriber_settings'
|
3
4
|
require 'circuitry/locks/base'
|
4
5
|
require 'circuitry/locks/memcache'
|
5
6
|
require 'circuitry/locks/memory'
|
@@ -15,23 +16,39 @@ require 'circuitry/subscriber'
|
|
15
16
|
require 'circuitry/version'
|
16
17
|
|
17
18
|
module Circuitry
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
class << self
|
20
|
+
def subscriber_config
|
21
|
+
@_sub_config ||= Config::SubscriberSettings.new
|
22
|
+
yield @_sub_config if block_given?
|
23
|
+
@_sub_config
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
def subscriber_config=(options)
|
27
|
+
@_sub_config = Config::SubscriberSettings.new(options)
|
28
|
+
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
def publisher_config
|
31
|
+
@_pub_config ||= Config::PublisherSettings.new
|
32
|
+
yield @_pub_config if block_given?
|
33
|
+
@_pub_config
|
34
|
+
end
|
35
|
+
|
36
|
+
def publisher_config=(options)
|
37
|
+
@_pub_config = Config::PublisherSettings.new(options)
|
38
|
+
end
|
39
|
+
|
40
|
+
def publish(topic_name, object, options = {})
|
41
|
+
Publisher.new(options).publish(topic_name, object)
|
42
|
+
end
|
43
|
+
|
44
|
+
def subscribe(options = {}, &block)
|
45
|
+
Subscriber.new(options).subscribe(&block)
|
46
|
+
end
|
31
47
|
|
32
|
-
|
33
|
-
|
34
|
-
|
48
|
+
def flush
|
49
|
+
Processors.constants.each do |const|
|
50
|
+
Processors.const_get(const).flush
|
51
|
+
end
|
35
52
|
end
|
36
53
|
end
|
37
54
|
end
|
data/lib/circuitry/cli.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
require 'circuitry/
|
1
|
+
require 'circuitry/provisioning'
|
2
2
|
require 'thor'
|
3
3
|
|
4
4
|
module Circuitry
|
5
5
|
class CLI < Thor
|
6
6
|
class_option :verbose, aliases: :v, type: :boolean
|
7
7
|
|
8
|
-
desc 'provision <queue> -t <topic> [<topic> ...]',
|
8
|
+
desc 'provision <queue> -t <topic> [<topic> ...]', <<-END
|
9
|
+
Provision a queue subscribed to one or more topics
|
10
|
+
END
|
9
11
|
|
10
12
|
long_desc <<-END
|
11
13
|
Creates an SQS queue with appropriate SNS access policy along with one or more SNS topics
|
@@ -21,18 +23,25 @@ module Circuitry
|
|
21
23
|
name <queue>-failures
|
22
24
|
END
|
23
25
|
|
24
|
-
option :
|
25
|
-
option :access_key, aliases: :a
|
26
|
-
option :secret_key, aliases: :s
|
27
|
-
option :
|
28
|
-
option :
|
26
|
+
option :topic_names, aliases: :t, type: :array, required: true
|
27
|
+
option :access_key, aliases: :a, required: true
|
28
|
+
option :secret_key, aliases: :s, required: true
|
29
|
+
option :region, aliases: :r, required: true
|
30
|
+
option :dead_letter_queue_name, aliases: :d
|
31
|
+
option :visibility_timeout, aliases: :v, default: 30 * 60
|
32
|
+
option :max_receive_count, aliases: :n, default: 8
|
33
|
+
|
34
|
+
OPTIONS_KEYS_PUBLISHER_CONFIG = [:access_key, :secret_key, :region].freeze
|
35
|
+
|
36
|
+
OPTIONS_KEYS_SUBSCRIBER_CONFIG = [:access_key, :secret_key, :region, :dead_letter_queue_name,
|
37
|
+
:topic_names, :max_receive_count, :visibility_timeout].freeze
|
29
38
|
|
30
39
|
def provision(queue_name)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
40
|
+
initialize_config(queue_name)
|
41
|
+
|
42
|
+
logger = Logger.new(STDOUT)
|
43
|
+
logger.level = Logger::INFO if options['verbose']
|
44
|
+
Circuitry::Provisioning.provision(logger: logger)
|
36
45
|
end
|
37
46
|
|
38
47
|
private
|
@@ -41,30 +50,21 @@ module Circuitry
|
|
41
50
|
puts(*args) if options['verbose']
|
42
51
|
end
|
43
52
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
original_values[sym] = Circuitry.config.send(sym)
|
48
|
-
end
|
49
|
-
|
50
|
-
assign_options_config(queue_name, original_values)
|
53
|
+
def initialize_config(queue_name)
|
54
|
+
Circuitry.publisher_config.topic_names = []
|
55
|
+
Circuitry.subscriber_config.queue_name = queue_name
|
51
56
|
|
52
|
-
|
53
|
-
ensure
|
54
|
-
restore_config(original_values)
|
57
|
+
assign_options_config
|
55
58
|
end
|
56
59
|
|
57
|
-
def assign_options_config
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
Circuitry.config.subscriber_queue_name = queue_name
|
62
|
-
Circuitry.config.subscriber_dead_letter_queue_name = options.fetch('dead_letter_queue', "#{queue_name}-failures")
|
63
|
-
Circuitry.config.publisher_topic_names = options['topics']
|
64
|
-
end
|
60
|
+
def assign_options_config
|
61
|
+
OPTIONS_KEYS_PUBLISHER_CONFIG.each do |key|
|
62
|
+
Circuitry.publisher_config.send(:"#{key}=", options[key.to_s])
|
63
|
+
end
|
65
64
|
|
66
|
-
|
67
|
-
|
65
|
+
OPTIONS_KEYS_SUBSCRIBER_CONFIG.each do |key|
|
66
|
+
Circuitry.subscriber_config.send(:"#{key}=", options[key.to_s])
|
67
|
+
end
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|