pheme 1.2.1 → 1.2.2
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 +16 -16
- data/.github/CODEOWNERS +1 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +16 -0
- data/.rubocop.yml +3 -3
- data/lib/pheme/compression.rb +1 -0
- data/lib/pheme/message_handler.rb +2 -1
- data/lib/pheme/queue_poller.rb +4 -2
- data/lib/pheme/rollbar.rb +1 -0
- data/lib/pheme/topic_publisher.rb +10 -2
- data/lib/pheme/version.rb +1 -1
- data/pheme.gemspec +2 -3
- data/spec/queue_poller_spec.rb +4 -4
- data/spec/support/example_with_arn_publisher.rb +3 -0
- data/spec/topic_publisher_spec.rb +12 -5
- metadata +8 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 89a8338f64d87daa837b51db3c2420f7a58b1c90145d269cd4bdf64d95e0e116
|
|
4
|
+
data.tar.gz: 4fd2cde4cc7738eaaa9c0f53b4372a9be5ff1dfc156667da3254023d3d2211f7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 293ff87ae4c74c81100cfffe3e45c62357f33ca48e29c65916e8e4f88026102c9c7caf85ff1599e9362f188d172d955091ac069634de806fb05b68d3f1b7fa58
|
|
7
|
+
data.tar.gz: 2cae0f28474ab6f5fa1ad7c89662423a0e1c8782d782b1e1e42a0da421d283316518de2eda9d0779f169a295cd777ea7986012be87af2cee1b39e679edc77d3e
|
data/.circleci/config.yml
CHANGED
|
@@ -20,7 +20,7 @@ references:
|
|
|
20
20
|
--out test_results/rspec.xml \
|
|
21
21
|
--format documentation \
|
|
22
22
|
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
bundle_audit: &bundle_audit
|
|
25
25
|
run:
|
|
26
26
|
name: Bundle audit
|
|
@@ -28,20 +28,20 @@ references:
|
|
|
28
28
|
|
|
29
29
|
version: 2
|
|
30
30
|
jobs:
|
|
31
|
-
|
|
31
|
+
build_2_3_8:
|
|
32
32
|
working_directory: ~/repo
|
|
33
33
|
docker:
|
|
34
|
-
- image: wealthsimple/ruby:2.3.
|
|
34
|
+
- image: wealthsimple/ruby:2.3.8-node-docker
|
|
35
35
|
environment:
|
|
36
36
|
RAILS_ENV: test
|
|
37
37
|
steps:
|
|
38
38
|
- checkout
|
|
39
39
|
- *which_bundler
|
|
40
40
|
- restore_cache:
|
|
41
|
-
key:
|
|
41
|
+
key: v1-ruby-2_3-{{ checksum "pheme.gemspec" }}-{{ checksum "Gemfile" }}
|
|
42
42
|
- *bundle_install
|
|
43
43
|
- save_cache:
|
|
44
|
-
key:
|
|
44
|
+
key: v1-ruby-2_3-{{ checksum "pheme.gemspec" }}-{{ checksum "Gemfile" }}
|
|
45
45
|
paths:
|
|
46
46
|
- vendor/bundle
|
|
47
47
|
- *run_rspec
|
|
@@ -49,20 +49,20 @@ jobs:
|
|
|
49
49
|
- store_test_results:
|
|
50
50
|
path: test_results
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
build_2_4_5:
|
|
53
53
|
working_directory: ~/repo
|
|
54
54
|
docker:
|
|
55
|
-
- image: wealthsimple/ruby:2.4.
|
|
55
|
+
- image: wealthsimple/ruby:2.4.5-node-docker
|
|
56
56
|
environment:
|
|
57
57
|
RAILS_ENV: test
|
|
58
58
|
steps:
|
|
59
59
|
- checkout
|
|
60
60
|
- *which_bundler
|
|
61
61
|
- restore_cache:
|
|
62
|
-
key:
|
|
62
|
+
key: v1-ruby-2_4-{{ checksum "pheme.gemspec" }}-{{ checksum "Gemfile" }}
|
|
63
63
|
- *bundle_install
|
|
64
64
|
- save_cache:
|
|
65
|
-
key:
|
|
65
|
+
key: v1-ruby-2_4-{{ checksum "pheme.gemspec" }}-{{ checksum "Gemfile" }}
|
|
66
66
|
paths:
|
|
67
67
|
- vendor/bundle
|
|
68
68
|
- *run_rspec
|
|
@@ -70,20 +70,20 @@ jobs:
|
|
|
70
70
|
- store_test_results:
|
|
71
71
|
path: test_results
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
build_2_5_3:
|
|
74
74
|
working_directory: ~/repo
|
|
75
75
|
docker:
|
|
76
|
-
- image: wealthsimple/ruby:2.5.
|
|
76
|
+
- image: wealthsimple/ruby:2.5.3-node-docker
|
|
77
77
|
environment:
|
|
78
78
|
RAILS_ENV: test
|
|
79
79
|
steps:
|
|
80
80
|
- checkout
|
|
81
81
|
- *which_bundler
|
|
82
82
|
- restore_cache:
|
|
83
|
-
key:
|
|
83
|
+
key: v1-ruby-2_5--{{ checksum "pheme.gemspec" }}-{{ checksum "Gemfile" }}
|
|
84
84
|
- *bundle_install
|
|
85
85
|
- save_cache:
|
|
86
|
-
key:
|
|
86
|
+
key: v1-ruby-2_5--{{ checksum "pheme.gemspec" }}-{{ checksum "Gemfile" }}
|
|
87
87
|
paths:
|
|
88
88
|
- vendor/bundle
|
|
89
89
|
- *run_rspec
|
|
@@ -95,6 +95,6 @@ workflows:
|
|
|
95
95
|
version: 2
|
|
96
96
|
build:
|
|
97
97
|
jobs:
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
98
|
+
- build_2_3_8
|
|
99
|
+
- build_2_4_5
|
|
100
|
+
- build_2_5_3
|
data/.github/CODEOWNERS
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @wealthsimple/developer-tools
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#### Why <!-- A short description of why this change is required -->
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
#### What changed <!-- Summary of changes when modifying hundreds of lines -->
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
<!--
|
|
10
|
+
Consider adding the following sections:
|
|
11
|
+
|
|
12
|
+
#### How I tested [ Bullets for test cases covered ]
|
|
13
|
+
#### Next steps [ If your PR is part of a few or a WIP, give context to reviewers ]
|
|
14
|
+
#### Screenshot [ An image is worth a thousand words ]
|
|
15
|
+
#### Bug/Ticket tracker [ Unnecessary when prefixing branch with JIRA ticket, e.g. SECURITY-123-human-readable-thing ]
|
|
16
|
+
-->
|
data/.rubocop.yml
CHANGED
|
@@ -11,7 +11,7 @@ AllCops:
|
|
|
11
11
|
- 'db/**/*'
|
|
12
12
|
- 'lib/tasks/circle_0.rake' # Ignore circleci code:
|
|
13
13
|
- 'node_modules/**/*'
|
|
14
|
-
TargetRubyVersion: 2.
|
|
14
|
+
TargetRubyVersion: 2.3
|
|
15
15
|
|
|
16
16
|
Lint/AmbiguousOperator:
|
|
17
17
|
Enabled: false
|
|
@@ -74,7 +74,7 @@ Style/Documentation:
|
|
|
74
74
|
Layout/TrailingBlankLines:
|
|
75
75
|
EnforcedStyle: final_newline
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
Naming/VariableName:
|
|
78
78
|
EnforcedStyle: snake_case
|
|
79
79
|
|
|
80
80
|
Style/MethodDefParentheses:
|
|
@@ -83,7 +83,7 @@ Style/MethodDefParentheses:
|
|
|
83
83
|
Style/Semicolon:
|
|
84
84
|
AllowAsExpressionSeparator: false
|
|
85
85
|
|
|
86
|
-
Style/
|
|
86
|
+
Style/TrailingCommaInHashLiteral:
|
|
87
87
|
EnforcedStyleForMultiline: comma
|
|
88
88
|
|
|
89
89
|
Style/Alias:
|
data/lib/pheme/compression.rb
CHANGED
data/lib/pheme/queue_poller.rb
CHANGED
|
@@ -8,6 +8,7 @@ module Pheme
|
|
|
8
8
|
|
|
9
9
|
def initialize(queue_url:, connection_pool_block: false, max_messages: nil, format: :json, poller_configuration: {}, sqs_client: nil)
|
|
10
10
|
raise ArgumentError, "must specify non-nil queue_url" unless queue_url.present?
|
|
11
|
+
|
|
11
12
|
@queue_url = queue_url
|
|
12
13
|
@queue_poller = Aws::SQS::QueuePoller.new(queue_url, client: sqs_client)
|
|
13
14
|
@connection_pool_block = connection_pool_block
|
|
@@ -70,6 +71,7 @@ module Pheme
|
|
|
70
71
|
else
|
|
71
72
|
method_name = "parse_#{format}".to_sym
|
|
72
73
|
raise ArgumentError, "Unknown format #{format}" unless respond_to?(method_name)
|
|
74
|
+
|
|
73
75
|
parsed_content = __send__(method_name, raw_content)
|
|
74
76
|
body['Records'] = parsed_content
|
|
75
77
|
end
|
|
@@ -146,7 +148,7 @@ module Pheme
|
|
|
146
148
|
end
|
|
147
149
|
|
|
148
150
|
def log_delete(queue_message)
|
|
149
|
-
Pheme.logger.
|
|
151
|
+
Pheme.logger.debug({
|
|
150
152
|
message: "#{self.class} deleted message #{queue_message.message_id}",
|
|
151
153
|
message_id: queue_message.message_id,
|
|
152
154
|
queue_poller: self.class.to_s,
|
|
@@ -155,7 +157,7 @@ module Pheme
|
|
|
155
157
|
end
|
|
156
158
|
|
|
157
159
|
def log_message_received(queue_message, body)
|
|
158
|
-
Pheme.logger.
|
|
160
|
+
Pheme.logger.debug({
|
|
159
161
|
message: "#{self.class} received message #{queue_message.message_id}",
|
|
160
162
|
queue_poller: self.class.to_s,
|
|
161
163
|
message_id: queue_message.message_id,
|
data/lib/pheme/rollbar.rb
CHANGED
|
@@ -15,12 +15,20 @@ module Pheme
|
|
|
15
15
|
EXPECTED_METADATA_SIZE = 1.kilobyte
|
|
16
16
|
MESSAGE_SIZE_LIMIT = SNS_SIZE_LIMIT - EXPECTED_METADATA_SIZE
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
class << self
|
|
19
|
+
attr_reader :_topic_arn
|
|
20
|
+
|
|
21
|
+
def topic_arn(topic_arn)
|
|
22
|
+
@_topic_arn = topic_arn
|
|
23
|
+
end
|
|
24
|
+
end
|
|
19
25
|
|
|
20
|
-
def initialize(topic_arn:)
|
|
26
|
+
def initialize(topic_arn: self.class._topic_arn)
|
|
21
27
|
raise ArgumentError, "must specify non-nil topic_arn" unless topic_arn.present?
|
|
28
|
+
|
|
22
29
|
@topic_arn = topic_arn
|
|
23
30
|
end
|
|
31
|
+
attr_accessor :topic_arn
|
|
24
32
|
|
|
25
33
|
def publish_events
|
|
26
34
|
raise NotImplementedError
|
data/lib/pheme/version.rb
CHANGED
data/pheme.gemspec
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
3
|
|
|
5
4
|
require "pheme/version"
|
|
@@ -18,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
|
18
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
19
18
|
gem.require_paths = ["lib"]
|
|
20
19
|
gem.licenses = ["MIT"]
|
|
21
|
-
gem.required_ruby_version = ">= 2.
|
|
20
|
+
gem.required_ruby_version = ">= 2.3.0"
|
|
22
21
|
|
|
23
22
|
gem.add_dependency "activesupport", ">= 4"
|
|
24
23
|
gem.add_dependency "aws-sdk-sns", "~> 1.1"
|
data/spec/queue_poller_spec.rb
CHANGED
|
@@ -55,14 +55,14 @@ describe Pheme::QueuePoller do
|
|
|
55
55
|
let(:expected_message) do
|
|
56
56
|
[
|
|
57
57
|
{ test1: 'value1', test2: 'value2' },
|
|
58
|
-
{ test1: 'value3', test2: 'value4' }
|
|
58
|
+
{ test1: 'value3', test2: 'value4' }
|
|
59
59
|
]
|
|
60
60
|
end
|
|
61
61
|
let(:message) do
|
|
62
62
|
[
|
|
63
63
|
%w[test1 test2].join(','),
|
|
64
64
|
%w[value1 value2].join(','),
|
|
65
|
-
%w[value3 value4].join(',')
|
|
65
|
+
%w[value3 value4].join(',')
|
|
66
66
|
].join("\n")
|
|
67
67
|
end
|
|
68
68
|
|
|
@@ -116,7 +116,7 @@ describe Pheme::QueuePoller do
|
|
|
116
116
|
let(:mock_connection_pool) { double }
|
|
117
117
|
subject { ExampleQueuePoller.new(queue_url: queue_url, connection_pool_block: true) }
|
|
118
118
|
let(:message) { { status: 'complete' } }
|
|
119
|
-
let(:notification) { { 'MessageId' => SecureRandom.uuid, 'Message' => message.to_json, 'Type' => 'Notification', 'Timestamp' => timestamp
|
|
119
|
+
let(:notification) { { 'MessageId' => SecureRandom.uuid, 'Message' => message.to_json, 'Type' => 'Notification', 'Timestamp' => timestamp } }
|
|
120
120
|
let!(:queue_message) do
|
|
121
121
|
OpenStruct.new(
|
|
122
122
|
body: notification.to_json,
|
|
@@ -140,7 +140,7 @@ describe Pheme::QueuePoller do
|
|
|
140
140
|
context "without connection pool block" do
|
|
141
141
|
subject { ExampleQueuePoller.new(queue_url: queue_url) }
|
|
142
142
|
let(:message) { { status: 'complete' } }
|
|
143
|
-
let(:notification) { { 'MessageId' => SecureRandom.uuid, 'Message' => message.to_json, 'Type' => 'Notification', 'Timestamp' => timestamp
|
|
143
|
+
let(:notification) { { 'MessageId' => SecureRandom.uuid, 'Message' => message.to_json, 'Type' => 'Notification', 'Timestamp' => timestamp } }
|
|
144
144
|
let!(:queue_message) do
|
|
145
145
|
OpenStruct.new(
|
|
146
146
|
body: notification.to_json,
|
|
@@ -13,6 +13,12 @@ describe Pheme::TopicPublisher do
|
|
|
13
13
|
expect { ExamplePublisher.new(topic_arn: nil) }.to raise_error(ArgumentError)
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
|
+
|
|
17
|
+
context "when topic_arn set via class setter" do
|
|
18
|
+
it "does not raise an error" do
|
|
19
|
+
expect { ExampleWithArnPublisher.new }.not_to raise_error
|
|
20
|
+
end
|
|
21
|
+
end
|
|
16
22
|
end
|
|
17
23
|
|
|
18
24
|
describe "#publish_events" do
|
|
@@ -59,11 +65,12 @@ describe Pheme::TopicPublisher do
|
|
|
59
65
|
|
|
60
66
|
it "publishes gzipped, base64 encoded message" do
|
|
61
67
|
expect(Pheme.configuration.sns_client).to(
|
|
62
|
-
receive(:publish)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
receive(:publish).
|
|
69
|
+
with({
|
|
70
|
+
topic_arn: topic_arn,
|
|
71
|
+
message: compressed_message,
|
|
72
|
+
}),
|
|
73
|
+
)
|
|
67
74
|
|
|
68
75
|
subject
|
|
69
76
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pheme
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter Graham
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -192,6 +192,8 @@ extensions: []
|
|
|
192
192
|
extra_rdoc_files: []
|
|
193
193
|
files:
|
|
194
194
|
- ".circleci/config.yml"
|
|
195
|
+
- ".github/CODEOWNERS"
|
|
196
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
|
195
197
|
- ".gitignore"
|
|
196
198
|
- ".rspec"
|
|
197
199
|
- ".rubocop.yml"
|
|
@@ -221,6 +223,7 @@ files:
|
|
|
221
223
|
- spec/support/example_message_handler.rb
|
|
222
224
|
- spec/support/example_publisher.rb
|
|
223
225
|
- spec/support/example_queue_poller.rb
|
|
226
|
+
- spec/support/example_with_arn_publisher.rb
|
|
224
227
|
- spec/topic_publisher_spec.rb
|
|
225
228
|
- spec/version_spec.rb
|
|
226
229
|
homepage: https://github.com/wealthsimple/pheme
|
|
@@ -235,7 +238,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
235
238
|
requirements:
|
|
236
239
|
- - ">="
|
|
237
240
|
- !ruby/object:Gem::Version
|
|
238
|
-
version: 2.
|
|
241
|
+
version: 2.3.0
|
|
239
242
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
243
|
requirements:
|
|
241
244
|
- - ">="
|
|
@@ -243,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
243
246
|
version: '0'
|
|
244
247
|
requirements: []
|
|
245
248
|
rubyforge_project:
|
|
246
|
-
rubygems_version: 2.
|
|
249
|
+
rubygems_version: 2.7.6
|
|
247
250
|
signing_key:
|
|
248
251
|
specification_version: 4
|
|
249
252
|
summary: Ruby SNS publisher + SQS poller & message handler
|
|
@@ -258,5 +261,6 @@ test_files:
|
|
|
258
261
|
- spec/support/example_message_handler.rb
|
|
259
262
|
- spec/support/example_publisher.rb
|
|
260
263
|
- spec/support/example_queue_poller.rb
|
|
264
|
+
- spec/support/example_with_arn_publisher.rb
|
|
261
265
|
- spec/topic_publisher_spec.rb
|
|
262
266
|
- spec/version_spec.rb
|