circuitry 3.2.0 → 3.3.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 +5 -5
- data/.circleci/config.yml +12 -0
- data/CHANGELOG.md +8 -0
- data/README.md +8 -2
- data/circuitry.gemspec +3 -1
- data/lib/circuitry/config/shared_settings.rb +1 -0
- data/lib/circuitry/config/subscriber_settings.rb +1 -0
- data/lib/circuitry/publisher.rb +22 -2
- data/lib/circuitry/services/sns.rb +1 -1
- data/lib/circuitry/services/sqs.rb +1 -1
- data/lib/circuitry/subscriber.rb +4 -2
- data/lib/circuitry/version.rb +1 -1
- metadata +23 -10
- data/circle.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d200bb856db00d87237c6425d03a31ab5953ac4962f7af81e9797b85f94ee921
|
4
|
+
data.tar.gz: 1bc9b5eac4c058f5f30ad035ae8f10dabf4921d0f3b35781a528856ba75459c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be4a3411b0e5a4535049dda1343e901a4abcb2ec81d2b76762dfe75460b1b5941031c0e50d5d3c1bca0b23700350497dfd40e5243b90e449b93ef36b76ab14d2
|
7
|
+
data.tar.gz: 245564d9b1d16e53b9086acc44446967705dcef54062f0747ae6b8cb50a601fb8822c3ef7444c09bb2e7355519667bb8c1cbfd45e16da29ea018f11d04cc7602
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## Circuitry 3.3.0 (June 23, 2020)
|
2
|
+
|
3
|
+
* Update AWS SDK to version 3 and use module sdk gems. *thogg4*
|
4
|
+
See https://github.com/aws/aws-sdk-ruby
|
5
|
+
Version 3 is backwards compatible with version 2.
|
6
|
+
* Catch `Aws::SNS::Errors::InvalidParameter` and rethrow with the topic
|
7
|
+
and message that caused the problem for improved debugging.
|
8
|
+
|
1
9
|
## Circuitry 3.2.0 (May 6, 2017)
|
2
10
|
|
3
11
|
* Fixed processing for `batch_size` of 1. *Xi Zhang*
|
data/README.md
CHANGED
@@ -116,9 +116,15 @@ production:
|
|
116
116
|
Available configuration options for *both* subscriber and publisher applications include:
|
117
117
|
|
118
118
|
* `access_key`: The AWS access key ID that has access to SNS publishing and/or
|
119
|
-
SQS subscribing. *(required)*
|
119
|
+
SQS subscribing. *(required unless using iam profile)*
|
120
120
|
* `secret_key`: The AWS secret access key that has access to SNS publishing
|
121
|
-
and/or SQS subscribing. *(required)*
|
121
|
+
and/or SQS subscribing. *(required unless using iam profile)*
|
122
|
+
* `use_iam_profile`: Whether or not to use an iam profile for authenticating to AWS.
|
123
|
+
This will only work when running your application inside of an AWS instance.
|
124
|
+
Accepts `true` or `false`
|
125
|
+
Please refer to the [AWS Docs](http://docs.aws.amazon.com/sdk-for-ruby/v2/developer-guide/setup-config.html#aws-ruby-sdk-credentials-iam)
|
126
|
+
for more details about using iam profiles for authentication.
|
127
|
+
*(required unless using access and secret keys, default: `false`)*
|
122
128
|
* `region`: The AWS region that your SNS and/or SQS account lives in.
|
123
129
|
*(optional, default: "us-east-1")*
|
124
130
|
* `logger`: The logger to use for informational output, warnings, and error
|
data/circuitry.gemspec
CHANGED
@@ -19,7 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.add_dependency 'aws-sdk'
|
22
|
+
spec.add_dependency 'aws-sdk-sqs'
|
23
|
+
spec.add_dependency 'aws-sdk-sns'
|
24
|
+
|
23
25
|
spec.add_dependency 'retries', '~> 0.0.5'
|
24
26
|
spec.add_dependency 'virtus', '~> 1.0'
|
25
27
|
spec.add_dependency 'thor'
|
@@ -9,6 +9,7 @@ module Circuitry
|
|
9
9
|
base.attribute :access_key, String
|
10
10
|
base.attribute :secret_key, String
|
11
11
|
base.attribute :region, String, default: 'us-east-1'
|
12
|
+
base.attribute :use_iam_profile, Virtus::Attribute::Boolean, default: false
|
12
13
|
base.attribute :logger, Logger, default: Logger.new(STDERR)
|
13
14
|
base.attribute :error_handler
|
14
15
|
base.attribute :topic_names, Array[String], default: []
|
data/lib/circuitry/publisher.rb
CHANGED
@@ -6,6 +6,17 @@ require 'circuitry/services/sns'
|
|
6
6
|
module Circuitry
|
7
7
|
class PublishError < StandardError; end
|
8
8
|
|
9
|
+
class SnsPublishError < StandardError
|
10
|
+
def initialize(topic:, message:, exception:)
|
11
|
+
msg = {
|
12
|
+
error: "#{exception.class}: #{exception.message}",
|
13
|
+
topic_arn: topic.arn,
|
14
|
+
message: message
|
15
|
+
}
|
16
|
+
super msg.to_json
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
9
20
|
class Publisher
|
10
21
|
include Concerns::Async
|
11
22
|
include Services::SNS
|
@@ -54,7 +65,7 @@ module Circuitry
|
|
54
65
|
# TODO: Don't use ruby timeout.
|
55
66
|
# http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/
|
56
67
|
Timeout.timeout(timeout) do
|
57
|
-
logger.
|
68
|
+
logger.debug("Publishing message to #{topic_name}")
|
58
69
|
|
59
70
|
handler = ->(error, attempt_number, _total_delay) do
|
60
71
|
logger.warn("Error publishing attempt ##{attempt_number}: #{error.class} (#{error.message}); retrying...")
|
@@ -62,7 +73,7 @@ module Circuitry
|
|
62
73
|
|
63
74
|
with_retries(max_tries: 3, handler: handler, rescue: CONNECTION_ERRORS, base_sleep_seconds: 0.05, max_sleep_seconds: 0.25) do
|
64
75
|
topic = Topic.find(topic_name)
|
65
|
-
|
76
|
+
sns_publish(topic: topic, message: message)
|
66
77
|
end
|
67
78
|
end
|
68
79
|
end
|
@@ -72,11 +83,20 @@ module Circuitry
|
|
72
83
|
|
73
84
|
private
|
74
85
|
|
86
|
+
def sns_publish(topic:, message:)
|
87
|
+
sns.publish(topic_arn: topic.arn, message: message)
|
88
|
+
|
89
|
+
rescue Aws::SNS::Errors::InvalidParameter => ex
|
90
|
+
raise SnsPublishError.new(topic: topic, message: message, exception: ex)
|
91
|
+
end
|
92
|
+
|
75
93
|
def logger
|
76
94
|
Circuitry.publisher_config.logger
|
77
95
|
end
|
78
96
|
|
79
97
|
def can_publish?
|
98
|
+
return true if Circuitry.publisher_config.use_iam_profile
|
99
|
+
|
80
100
|
Circuitry.publisher_config.aws_options.values.all? do |value|
|
81
101
|
!value.nil? && !value.empty?
|
82
102
|
end
|
data/lib/circuitry/subscriber.rb
CHANGED
@@ -132,7 +132,7 @@ module Circuitry
|
|
132
132
|
def process_message(message, &block)
|
133
133
|
message = Message.new(message)
|
134
134
|
|
135
|
-
logger.
|
135
|
+
logger.debug("Processing message #{message.id}")
|
136
136
|
|
137
137
|
handled = try_with_lock(message.id) do
|
138
138
|
handle_message_with_middleware(message, &block)
|
@@ -179,7 +179,7 @@ module Circuitry
|
|
179
179
|
end
|
180
180
|
|
181
181
|
def delete_message(message)
|
182
|
-
logger.
|
182
|
+
logger.debug("Removing message #{message.id} from queue")
|
183
183
|
sqs.delete_message(queue_url: queue, receipt_handle: message.receipt_handle)
|
184
184
|
end
|
185
185
|
|
@@ -192,6 +192,8 @@ module Circuitry
|
|
192
192
|
end
|
193
193
|
|
194
194
|
def can_subscribe?
|
195
|
+
return true if Circuitry.subscriber_config.use_iam_profile
|
196
|
+
|
195
197
|
Circuitry.subscriber_config.aws_options.values.all? do |value|
|
196
198
|
!value.nil? && !value.empty?
|
197
199
|
end
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Huggins
|
@@ -9,22 +9,36 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: aws-sdk
|
15
|
+
name: aws-sdk-sqs
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: aws-sdk-sns
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: retries
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -231,6 +245,7 @@ executables:
|
|
231
245
|
extensions: []
|
232
246
|
extra_rdoc_files: []
|
233
247
|
files:
|
248
|
+
- ".circleci/config.yml"
|
234
249
|
- ".gitignore"
|
235
250
|
- ".rspec"
|
236
251
|
- ".rubocop.yml"
|
@@ -241,7 +256,6 @@ files:
|
|
241
256
|
- Rakefile
|
242
257
|
- bin/console
|
243
258
|
- bin/setup
|
244
|
-
- circle.yml
|
245
259
|
- circuitry.gemspec
|
246
260
|
- exe/circuitry
|
247
261
|
- lib/circuitry.rb
|
@@ -297,8 +311,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
311
|
- !ruby/object:Gem::Version
|
298
312
|
version: '0'
|
299
313
|
requirements: []
|
300
|
-
|
301
|
-
rubygems_version: 2.6.10
|
314
|
+
rubygems_version: 3.0.3
|
302
315
|
signing_key:
|
303
316
|
specification_version: 4
|
304
317
|
summary: Decouple ruby applications using Amazon SNS fanout with SQS processing.
|