pheme 5.3.4 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 219b35c7c69ba33d474d1063586cc0d357a4ab129b84eb80a9d9229570680a15
4
- data.tar.gz: 3dce2f5202292466c7f4653e2b68928121a7b9aa5ba0c51375d01d0575159510
3
+ metadata.gz: 5c1f36f4d154e2fbd0ef4c5ff2c883e73568ac9ff6f7db10d555eba44f571241
4
+ data.tar.gz: e07dea65651b220d142bda320ae759d2bafc2a4c88ca480f353755ad7d7e08df
5
5
  SHA512:
6
- metadata.gz: e76e2a025181932da7cb730fa624e2ff101a5e48bf565bec1b1e75448ee59c3a92b16c79444014ca1ef202db0cfb944f03214afdffcb13b8bc62ca6e54d5764a
7
- data.tar.gz: db2eced35f5b27bd0db443aaaa7825008c25dd06b2c3a4c4c2173435f92ace7dbf056e48604cdb0d2b0b2f76ab94a8ea26a733f939d338523253c0e3f4e9afd4
6
+ metadata.gz: 790ad3e1a93632eafa4f591c49dc51999becc8746abe433c6f972cfc07c0d17cc07e8402b75b74e6368006bb48633c1ad9d10dc1f190e1bb1965c7fd0295dc50
7
+ data.tar.gz: 790646a9e3f3a14695f3f6cba9d9954eaf09e1579da1b8bb49a9e70fb42b58b20d19114eb2f3669cd53716830add50e1a53fb0ab0b7d766df020a8a5cf1b865e
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2024-06-14 14:59:19 UTC using RuboCop version 1.64.1.
3
+ # on 2024-07-04 21:40:31 UTC using RuboCop version 1.64.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -19,20 +19,19 @@ RSpec/NoExpectationExample:
19
19
  - 'spec/logger_spec.rb'
20
20
  - 'spec/queue_poller_spec.rb'
21
21
 
22
- # Offense count: 9
22
+ # Offense count: 8
23
23
  # Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
24
24
  # Include: **/*_spec.rb
25
25
  RSpec/SpecFilePathFormat:
26
26
  Exclude:
27
27
  - 'spec/configuration_spec.rb'
28
+ - 'spec/error_reporting_spec.rb'
28
29
  - 'spec/logger_spec.rb'
29
30
  - 'spec/message_handler_spec.rb'
30
31
  - 'spec/message_type/aws_event_spec.rb'
31
32
  - 'spec/message_type/sns_message_spec.rb'
32
33
  - 'spec/queue_poller_spec.rb'
33
- - 'spec/rollbar_spec.rb'
34
34
  - 'spec/topic_publisher_spec.rb'
35
- - 'spec/version_spec.rb'
36
35
 
37
36
  # Offense count: 2
38
37
  # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
data/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 6.0.0 - 2024-07-04
10
+ ### Changed
11
+ - **breaking changes** Removed support for Rollbar configuration. `config.rollbar` is no longer supported.
12
+ - Added support for passing `error_reporting_func` as a config option.
13
+
9
14
  ## 5.3.4 - 2024-06-14
10
15
  ### Changed
11
16
  - Updated dependencies
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pheme (5.3.4)
4
+ pheme (6.0.0)
5
5
  activesupport (>= 4)
6
6
  aws-sdk-sns (~> 1.1)
7
7
  aws-sdk-sqs (~> 1.3)
@@ -72,7 +72,7 @@ GEM
72
72
  process_executer (1.1.0)
73
73
  public_suffix (5.0.5)
74
74
  racc (1.8.0)
75
- rack (3.1.3)
75
+ rack (3.1.6)
76
76
  rainbow (3.1.1)
77
77
  rake (13.2.1)
78
78
  rchardet (1.8.0)
data/README.md CHANGED
@@ -34,6 +34,13 @@ Pheme.configure do |config|
34
34
  config.sqs_client = AWS_SQS_CLIENT
35
35
  config.sns_client = AWS_SNS_CLIENT
36
36
  config.logger = Logger.new(STDOUT) # Optionally replace with your app logger, e.g. `Rails.logger`
37
+
38
+ # Internal wealthsimple error handler
39
+ config.error_reporting_func = Ws::Railway::ErrorReporting.capture_exception
40
+ # Sentry
41
+ config.error_reporting_func = Sentry.capture_exception
42
+ # Rollbar
43
+ config.error_reporting_func = Rollbar.error
37
44
  end
38
45
  ```
39
46
 
@@ -17,9 +17,10 @@ module Pheme
17
17
 
18
18
  class Configuration
19
19
  ATTRIBUTES = %i[sns_client sqs_client logger].freeze
20
- OPTIONAL_ATTRIBUTES = %i[rollbar].freeze
20
+ OPTIONAL_ATTRIBUTES = %i[error_reporting_func].freeze
21
+ DEPRECATED_ATTRIBUTES = %i[rollbar].freeze
21
22
 
22
- attr_accessor(*ATTRIBUTES, *OPTIONAL_ATTRIBUTES)
23
+ attr_accessor(*ATTRIBUTES, *OPTIONAL_ATTRIBUTES, *DEPRECATED_ATTRIBUTES)
23
24
 
24
25
  def initialize
25
26
  @logger ||= Logger.new($stdout) # rubocop:disable Lint/DisjunctiveAssignmentInConstructor
@@ -32,6 +33,10 @@ module Pheme
32
33
  end
33
34
  raise "sns_client must be a Aws::SNS::Client" unless sns_client.is_a?(Aws::SNS::Client)
34
35
  raise "sns_client must be a Aws::SQS::Client" unless sqs_client.is_a?(Aws::SQS::Client)
36
+
37
+ if respond_to?(:rollbar)
38
+ @logger.warn("config.rollbar is deprecated. Please use config.error_reporting_func instead.")
39
+ end
35
40
  end
36
41
  end
37
42
  end
@@ -0,0 +1,7 @@
1
+ module Pheme
2
+ def self.capture_exception(exception, message, data = {})
3
+ return if configuration.error_reporting_func.nil?
4
+
5
+ configuration.error_reporting_func.call(exception, message, data)
6
+ end
7
+ end
@@ -69,7 +69,7 @@ module Pheme
69
69
  throw :stop_polling
70
70
  rescue StandardError => e
71
71
  Pheme.logger.error(e)
72
- Pheme.rollbar(e, "#{self.class} failed to process message", { message: content })
72
+ Pheme.capture_exception(e, "#{self.class} failed to process message", { message: content })
73
73
  end
74
74
  end
75
75
  log_polling_end(time_start)
data/lib/pheme/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pheme
2
- VERSION = '5.3.4'.freeze
2
+ VERSION = '6.0.0'.freeze
3
3
  end
data/lib/pheme.rb CHANGED
@@ -8,7 +8,7 @@ require 'smarter_csv'
8
8
  require 'pheme/version'
9
9
  require 'pheme/configuration'
10
10
  require 'pheme/logger'
11
- require 'pheme/rollbar'
11
+ require 'pheme/error_reporting'
12
12
  require 'pheme/topic_publisher'
13
13
  require 'pheme/message_handler'
14
14
  require 'pheme/queue_poller'
@@ -49,6 +49,26 @@ describe Pheme do
49
49
  expect { subject }.not_to raise_error
50
50
  end
51
51
  end
52
+
53
+ context 'deprecated attributes' do
54
+ let(:sns_client) { instance_double(Aws::SNS::Client) }
55
+ let(:sqs_client) { instance_double(Aws::SQS::Client) }
56
+
57
+ before do
58
+ allow(sns_client).to receive(:is_a?).with(Aws::SNS::Client).and_return(true)
59
+ allow(sqs_client).to receive(:is_a?).with(Aws::SQS::Client).and_return(true)
60
+
61
+ configuration.sns_client = sns_client
62
+ configuration.sqs_client = sqs_client
63
+ configuration.rollbar = double
64
+ end
65
+
66
+ it "warns if passed a deprecated config attribute" do
67
+ expect(configuration.logger).to receive(:warn).with("config.rollbar is deprecated. Please use config.error_reporting_func instead.")
68
+
69
+ expect { subject }.not_to raise_error
70
+ end
71
+ end
52
72
  end
53
73
  end
54
74
  end
@@ -0,0 +1,22 @@
1
+ RSpec.describe Pheme do
2
+ let(:error_reporting_func) { double }
3
+
4
+ describe '.capture_exception' do
5
+ subject { described_class.capture_exception(exception, message, data) }
6
+
7
+ let(:exception) { StandardError }
8
+ let(:message) { 'Unable to poll for messages' }
9
+ let(:data) { { sqs_url: 'arn::foo::bar' } }
10
+
11
+ before do
12
+ described_class.configure do |config|
13
+ config.error_reporting_func = error_reporting_func
14
+ end
15
+ end
16
+
17
+ it 'sends error message to configured error_reporter' do
18
+ expect(error_reporting_func).to receive(:call).with(exception, message, data)
19
+ subject
20
+ end
21
+ end
22
+ 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: 5.3.4
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Graham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-02 00:00:00.000000000 Z
11
+ date: 2024-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -247,23 +247,23 @@ files:
247
247
  - lib/pheme.rb
248
248
  - lib/pheme/compression.rb
249
249
  - lib/pheme/configuration.rb
250
+ - lib/pheme/error_reporting.rb
250
251
  - lib/pheme/logger.rb
251
252
  - lib/pheme/message_handler.rb
252
253
  - lib/pheme/message_type/aws_event.rb
253
254
  - lib/pheme/message_type/sns_message.rb
254
255
  - lib/pheme/queue_poller.rb
255
- - lib/pheme/rollbar.rb
256
256
  - lib/pheme/topic_publisher.rb
257
257
  - lib/pheme/version.rb
258
258
  - pheme.gemspec
259
259
  - sonar-project.properties
260
260
  - spec/configuration_spec.rb
261
+ - spec/error_reporting_spec.rb
261
262
  - spec/logger_spec.rb
262
263
  - spec/message_handler_spec.rb
263
264
  - spec/message_type/aws_event_spec.rb
264
265
  - spec/message_type/sns_message_spec.rb
265
266
  - spec/queue_poller_spec.rb
266
- - spec/rollbar_spec.rb
267
267
  - spec/spec_helper.rb
268
268
  - spec/support/example_aws_event_queue_poller.rb
269
269
  - spec/support/example_message_handler.rb
data/lib/pheme/rollbar.rb DELETED
@@ -1,7 +0,0 @@
1
- module Pheme
2
- def self.rollbar(exception, message, data = {})
3
- return if configuration.rollbar.nil?
4
-
5
- configuration.rollbar.error(exception, message, data)
6
- end
7
- end
data/spec/rollbar_spec.rb DELETED
@@ -1,22 +0,0 @@
1
- RSpec.describe Pheme do
2
- let(:rollbar) { double }
3
-
4
- describe '.rollbar' do
5
- subject { described_class.rollbar(exception, message, data) }
6
-
7
- let(:exception) { StandardError }
8
- let(:message) { 'Unable to poll for messages' }
9
- let(:data) { { sqs_url: 'arn::foo::bar' } }
10
-
11
- before do
12
- described_class.configure do |config|
13
- config.rollbar = rollbar
14
- end
15
- end
16
-
17
- it 'sends error message to rollbar' do
18
- expect(rollbar).to receive(:error).with(exception, message, data)
19
- subject
20
- end
21
- end
22
- end