hermes_messenger_of_the_gods 2.4.0.pre2 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -1
  3. data/.rubocop.yml +7 -0
  4. data/Gemfile +4 -2
  5. data/Rakefile +5 -3
  6. data/bin/console +4 -3
  7. data/exe/fly_hermes +6 -11
  8. data/hermes_messenger_of_the_gods.gemspec +2 -1
  9. data/lib/hermes_messenger_of_the_gods/concerns/base.rb +1 -1
  10. data/lib/hermes_messenger_of_the_gods/concerns/grpc_protobuf.rb +1 -4
  11. data/lib/hermes_messenger_of_the_gods/concerns/message.rb +1 -3
  12. data/lib/hermes_messenger_of_the_gods/concerns/worker.rb +3 -1
  13. data/lib/hermes_messenger_of_the_gods/configuration.rb +4 -2
  14. data/lib/hermes_messenger_of_the_gods/endpoint_builder.rb +9 -3
  15. data/lib/hermes_messenger_of_the_gods/endpoints/base.rb +5 -3
  16. data/lib/hermes_messenger_of_the_gods/endpoints/sns.rb +1 -1
  17. data/lib/hermes_messenger_of_the_gods/endpoints/sqs.rb +16 -20
  18. data/lib/hermes_messenger_of_the_gods/endpoints.rb +2 -0
  19. data/lib/hermes_messenger_of_the_gods/exceptions.rb +1 -0
  20. data/lib/hermes_messenger_of_the_gods/logging_helpers.rb +2 -0
  21. data/lib/hermes_messenger_of_the_gods/output/basic.rb +14 -10
  22. data/lib/hermes_messenger_of_the_gods/status_server.rb +1 -0
  23. data/lib/hermes_messenger_of_the_gods/testing/array_endpoint.rb +1 -1
  24. data/lib/hermes_messenger_of_the_gods/testing/dispatch_matcher.rb +2 -3
  25. data/lib/hermes_messenger_of_the_gods/testing/rspec_helpers.rb +8 -5
  26. data/lib/hermes_messenger_of_the_gods/version.rb +3 -1
  27. metadata +21 -41
  28. data/vendor/cache/addressable-2.8.0.gem +0 -0
  29. data/vendor/cache/aws-eventstream-1.2.0.gem +0 -0
  30. data/vendor/cache/codeclimate-test-reporter-1.0.7.gem +0 -0
  31. data/vendor/cache/coderay-1.1.3.gem +0 -0
  32. data/vendor/cache/coveralls_reborn-0.22.0.gem +0 -0
  33. data/vendor/cache/crack-0.4.5.gem +0 -0
  34. data/vendor/cache/diff-lcs-1.4.4.gem +0 -0
  35. data/vendor/cache/docile-1.4.0.gem +0 -0
  36. data/vendor/cache/google-protobuf-3.18.0-universal-darwin.gem +0 -0
  37. data/vendor/cache/google-protobuf-3.18.0-x86_64-linux.gem +0 -0
  38. data/vendor/cache/googleapis-common-protos-types-1.2.0.gem +0 -0
  39. data/vendor/cache/grpc-1.40.0-universal-darwin.gem +0 -0
  40. data/vendor/cache/grpc-1.40.0-x86_64-linux.gem +0 -0
  41. data/vendor/cache/hashdiff-1.0.1.gem +0 -0
  42. data/vendor/cache/memory_profiler-1.0.0.gem +0 -0
  43. data/vendor/cache/method_source-1.0.0.gem +0 -0
  44. data/vendor/cache/pry-0.14.1.gem +0 -0
  45. data/vendor/cache/public_suffix-4.0.6.gem +0 -0
  46. data/vendor/cache/rake-10.5.0.gem +0 -0
  47. data/vendor/cache/rexml-3.2.5.gem +0 -0
  48. data/vendor/cache/rspec-3.10.0.gem +0 -0
  49. data/vendor/cache/rspec-core-3.10.1.gem +0 -0
  50. data/vendor/cache/rspec-expectations-3.10.1.gem +0 -0
  51. data/vendor/cache/rspec-mocks-3.10.2.gem +0 -0
  52. data/vendor/cache/rspec-support-3.10.2.gem +0 -0
  53. data/vendor/cache/simplecov-0.21.2.gem +0 -0
  54. data/vendor/cache/simplecov-html-0.12.3.gem +0 -0
  55. data/vendor/cache/simplecov-lcov-0.8.0.gem +0 -0
  56. data/vendor/cache/simplecov_json_formatter-0.1.3.gem +0 -0
  57. data/vendor/cache/sync-0.5.0.gem +0 -0
  58. data/vendor/cache/term-ansicolor-1.7.1.gem +0 -0
  59. data/vendor/cache/thor-1.1.0.gem +0 -0
  60. data/vendor/cache/timecop-0.9.4.gem +0 -0
  61. data/vendor/cache/tins-1.29.1.gem +0 -0
  62. data/vendor/cache/webmock-3.14.0.gem +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 306982bf98f79ad4a92c01b8cbf7ba68acf8173904d3adc8fde204b746c8a2a7
4
- data.tar.gz: efd5cca6cced4209b4c663d77e6ad4d26e80c084b9de29422f691d6f814d257a
3
+ metadata.gz: b3ad7cd6b63d696cd8e765e69def47efa4496c43e1573b9dc80a966f770df0da
4
+ data.tar.gz: 627776d0de4ac041fc22b6cb35c3fe2f8ee2d873375599c6136b54d00bc46d29
5
5
  SHA512:
6
- metadata.gz: 3b12f3abc2b2cfb6da3a4d1d0991cecd42d76ebb6c9cb4d4625abbb915112b3bb07860842ad318a55de9b8a627b71c3be7ed5d49056c4b969765da8a637ac84e
7
- data.tar.gz: ceb1f94c06e19be4f9b5ab630b78ea6e723b63ca8ad4d8d74f2168c4ecfef2c60207e1ca324b09474166a960b16c824510449de78f1d73bba519f075ce63b37d
6
+ metadata.gz: 56035ce71cfc68f0e593a6ffc81236ef8512ab186f459f1b6d29f6322e161862951ba4fe82210cdee8ab189023ef4ef7fd31452f6f4df822be1d39578cfc79e9
7
+ data.tar.gz: 74a55d8d43193c40f7e0e345a8dfe81fc72c3674202ed29c997259f30acf8ebda468e6b920fe88e8dbc28b5018eabf2e208cf23ae533c5f592442e60c69941af
@@ -27,7 +27,7 @@ jobs:
27
27
  run: >
28
28
  bash -c "
29
29
  mkdir -p /coverage;
30
- bundle --local;
30
+ bundle;
31
31
  COVERALLS_NOISY=true bundle exec rspec --color --format documentation;"
32
32
 
33
33
  - name: Push Coveralls
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/GetTerminus/ruby_shared_configs/master/.rubocop-3-1.yml
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - '**/*_pb.rb'
7
+ - 'vendor/**/*'
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in hermes-messenger-of-the-gods.gemspec
@@ -6,8 +8,8 @@ gemspec
6
8
  gem 'grpc'
7
9
 
8
10
  group :test do
11
+ gem 'codeclimate-test-reporter', '~> 1.0.0'
9
12
  gem 'coveralls_reborn', '~> 0.22.0', require: false
10
- gem "codeclimate-test-reporter", "~> 1.0.0"
11
13
  gem 'simplecov-lcov', '~> 0.8.0'
12
- gem "webmock"
14
+ gem 'webmock'
13
15
  end
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "hermes_messenger_of_the_gods"
4
+ require 'bundler/setup'
5
+ require 'hermes_messenger_of_the_gods'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "hermes_messenger_of_the_gods"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/exe/fly_hermes CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'thor'
4
5
  require 'bundler/setup'
@@ -12,32 +13,26 @@ class FlyHermes < Thor
12
13
  method_option :name, type: :string
13
14
 
14
15
  def start
15
- if options[:require]
16
- require options[:require]
17
- else
18
- require File.expand_path('config/environment.rb')
19
- end
16
+ require options[:require] || File.expand_path('config/environment.rb')
20
17
 
21
18
  pools = []
22
19
  if options[:worker]
23
- pools << [options[:worker].constantize, 1]
20
+ pools << [options[:worker].constantize, 1]
24
21
  elsif options[:pool]
25
22
 
26
23
  options[:pool].each do |pool|
27
24
  pool_klass, pool_size = pool.split('--', 2)
28
25
  pool_size = pool_size.to_i if pool_size
29
- raise "Pool size must be > 0" if pool_size.nil? or pool_size < 1
26
+ raise 'Pool size must be > 0' if pool_size.nil? || (pool_size < 1)
30
27
 
31
28
  pools << [
32
29
  pool_klass.constantize,
33
- pool_size
30
+ pool_size,
34
31
  ]
35
32
  end
36
33
  end
37
34
 
38
- if pools.empty?
39
- raise "No workers specified. --worker or --pool is required"
40
- end
35
+ raise 'No workers specified. --worker or --pool is required' if pools.empty?
41
36
 
42
37
  pools.each do |worker_klass, count|
43
38
  count.times do |i|
@@ -33,13 +33,14 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency 'activesupport', '> 4.2.3'
34
34
  spec.add_dependency 'aws-sdk-sns', '~> 1.0'
35
35
  spec.add_dependency 'aws-sdk-sqs', '~> 1.0'
36
- spec.add_dependency 'thor'
37
36
  spec.add_dependency 'rexml'
37
+ spec.add_dependency 'thor'
38
38
 
39
39
  spec.add_development_dependency 'bundler', '~> 2.0'
40
40
  spec.add_development_dependency 'memory_profiler'
41
41
  spec.add_development_dependency 'pry'
42
42
  spec.add_development_dependency 'rake', '~> 10.0'
43
43
  spec.add_development_dependency 'rspec', '~> 3.0'
44
+ spec.add_development_dependency 'rubocop'
44
45
  spec.add_development_dependency 'timecop'
45
46
  end
@@ -16,7 +16,7 @@ module HermesMessengerOfTheGods
16
16
  name = [
17
17
  'hermes_messenger_of_the_gods',
18
18
  notification_prefix,
19
- name
19
+ name,
20
20
  ].reject(&:blank?).join('.')
21
21
 
22
22
  payload[_instrument_key] ||= self if _instrument_key
@@ -10,9 +10,7 @@ module HermesMessengerOfTheGods
10
10
 
11
11
  alias_method :_pre_grpc_protobuff_init, :initialize
12
12
  def initialize(protobuf, options = {})
13
- unless protobuf.is_a?(self.class._protobuf_class)
14
- raise "#{self.class} requires a Protobuf for initialization"
15
- end
13
+ raise "#{self.class} requires a Protobuf for initialization" unless protobuf.is_a?(self.class._protobuf_class)
16
14
 
17
15
  _pre_grpc_protobuff_init(protobuf.to_h.merge!(options))
18
16
  end
@@ -31,7 +29,6 @@ module HermesMessengerOfTheGods
31
29
  # Build a proto with the incoming hash
32
30
  self.class._protobuf_class.new(to_message)
33
31
  end
34
-
35
32
  end
36
33
 
37
34
  class_methods do
@@ -52,9 +52,7 @@ module HermesMessengerOfTheGods
52
52
 
53
53
  def retry_at(future_time_or_seconds_in_future)
54
54
  raise 'unable to set visiblity' if source_endpoint.nil? || original_message.nil?
55
- unless source_endpoint.respond_to?(:set_reexecution_time)
56
- raise "endpoint type doesn't support setting execution time"
57
- end
55
+ raise "endpoint type doesn't support setting execution time" unless source_endpoint.respond_to?(:set_reexecution_time)
58
56
 
59
57
  source_endpoint.set_reexecution_time(original_message, future_time_or_seconds_in_future)
60
58
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
 
3
5
  require_relative './base'
@@ -65,7 +67,7 @@ module HermesMessengerOfTheGods
65
67
  circuit_breaker_error = self.class.circuit_breaker_errors[matching_circuit_breaker_error]
66
68
  sleep_time = circuit_breaker_error[:sleep] || 0
67
69
  Kernel.sleep(sleep_time) unless sleep_time.zero?
68
- raise e if !!circuit_breaker_error[:fatal]
70
+ raise e unless circuit_breaker_error[:fatal].nil?
69
71
  end
70
72
  throw(:skip_delete, true)
71
73
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logger'
2
4
 
3
5
  module HermesMessengerOfTheGods
@@ -10,7 +12,7 @@ module HermesMessengerOfTheGods
10
12
  if instance_variable_defined?("@#{meth}")
11
13
  instance_variable_get("@#{meth}")
12
14
  else
13
- instance_variable_set("@#{meth}", default.respond_to?(:call) ? default.call() : default)
15
+ instance_variable_set("@#{meth}", default.respond_to?(:call) ? default.call : default)
14
16
  end
15
17
  end
16
18
  end
@@ -18,7 +20,7 @@ module HermesMessengerOfTheGods
18
20
 
19
21
  # Log location for HMOTG info messages. Should respond like your
20
22
  # typical Ruby Logger defaults to logging via STDOUT
21
- attr_accessor_with_default :logger, Logger.new(STDOUT)
23
+ attr_accessor_with_default :logger, Logger.new($stdout)
22
24
 
23
25
  attr_accessor_with_default :quiet, false
24
26
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
 
3
5
  module HermesMessengerOfTheGods
@@ -18,20 +20,24 @@ module HermesMessengerOfTheGods
18
20
  class_methods do
19
21
  def is_valid_endpoint_creation_method(method)
20
22
  method.to_s =~ /(\w+)_endpoint\z/ &&
21
- ("HermesMessengerOfTheGods::Endpoints::#{$1.camelize}".constantize rescue nil)
23
+ begin
24
+ "HermesMessengerOfTheGods::Endpoints::#{::Regexp.last_match(1).camelize}".constantize
25
+ rescue StandardError
26
+ nil
27
+ end
22
28
  end
23
29
 
24
30
  def method_missing(method, *args, &blk)
25
31
  klass = is_valid_endpoint_creation_method(method)
26
32
  if klass
27
- {klass: klass, args: args}
33
+ { klass: klass, args: args }
28
34
  else
29
35
  super(method, *args, &blk)
30
36
  end
31
37
  end
32
38
 
33
39
  def build_endpoints
34
- self.endpoints.each.with_object({}) do |(k,v), hsh|
40
+ endpoints.each.with_object({}) do |(k, v), hsh|
35
41
  hsh[k] = EndpointBuilder.build(k, v[:klass], *v[:args])
36
42
  end
37
43
  end
@@ -12,7 +12,7 @@ module HermesMessengerOfTheGods
12
12
  DEFAULT_OPTIONS = { retries: 3, jitter: true, backoff: :linear, jsonify: true }.freeze
13
13
  DEFAULT_RETRYS = {
14
14
  linear: ->(n) { n }, # Wait 1 sec, then two secondns, then three...
15
- exponential: ->(n) { (2**n) / (n + 1).to_f } # Wait 1, then 1.3, then 2 sec
15
+ exponential: ->(n) { (2**n) / (n + 1).to_f }, # Wait 1, then 1.3, then 2 sec
16
16
  }.freeze
17
17
 
18
18
  attr_accessor :options, :endpoint, :errors, :result, :name
@@ -75,9 +75,11 @@ module HermesMessengerOfTheGods
75
75
  transformer_name = "to_#{self.class.to_s.demodulize.underscore}_message"
76
76
 
77
77
  if options[:transformer]
78
- options[:transformer].respond_to?(:call) ?
79
- options[:transformer].call(message) :
78
+ if options[:transformer].respond_to?(:call)
79
+ options[:transformer].call(message)
80
+ else
80
81
  message.send(options[:transformer])
82
+ end
81
83
  elsif message.respond_to?(transformer_name)
82
84
  message.public_send(transformer_name)
83
85
  elsif message.respond_to?(:_build_for_transmission)
@@ -9,7 +9,7 @@ module HermesMessengerOfTheGods
9
9
  def sns_topic
10
10
  @sns_topic ||= Aws::SNS::Topic.new(endpoint,
11
11
  {
12
- client: HermesMessengerOfTheGods.configuration.sns_client
12
+ client: HermesMessengerOfTheGods.configuration.sns_client,
13
13
  }.merge(options[:client_options] || {}))
14
14
  end
15
15
 
@@ -20,8 +20,8 @@ module HermesMessengerOfTheGods
20
20
  @poller ||= Aws::SQS::QueuePoller.new(
21
21
  endpoint,
22
22
  {
23
- client: HermesMessengerOfTheGods.configuration.sqs_client
24
- }.merge(options[:client_options] || {})
23
+ client: HermesMessengerOfTheGods.configuration.sqs_client,
24
+ }.merge(options[:client_options] || {}),
25
25
  )
26
26
  end
27
27
 
@@ -76,14 +76,10 @@ module HermesMessengerOfTheGods
76
76
  shutting_down? ? :shutdown : work_message(msg, &blk)
77
77
  end
78
78
 
79
- unless completion_results.fetch(true, []).empty?
80
- poller.delete_messages(completion_results[true] & inflight_messages)
81
- end
79
+ poller.delete_messages(completion_results[true] & inflight_messages) unless completion_results.fetch(true, []).empty?
82
80
  # Messages skipped due to shutdowns get their visibility set back to 0 so they restart
83
81
  # normal failed jobs will be left in queue until their visibility timeout expires to indicate a backoff
84
- unless completion_results.fetch(:shutdown, []).empty?
85
- set_message_visibility(completion_results[:shutdown] & inflight_messages, 0)
86
- end
82
+ set_message_visibility(completion_results[:shutdown] & inflight_messages, 0) unless completion_results.fetch(:shutdown, []).empty?
87
83
  end
88
84
  end
89
85
  end
@@ -123,8 +119,8 @@ module HermesMessengerOfTheGods
123
119
  @queue ||= Aws::SQS::Queue.new(
124
120
  endpoint,
125
121
  {
126
- client: HermesMessengerOfTheGods.configuration.sqs_client
127
- }.merge(options[:client_options] || {})
122
+ client: HermesMessengerOfTheGods.configuration.sqs_client,
123
+ }.merge(options[:client_options] || {}),
128
124
  )
129
125
  end
130
126
 
@@ -140,7 +136,7 @@ module HermesMessengerOfTheGods
140
136
  data['ApproximateNumberOfMessagesDelayed'].to_i
141
137
 
142
138
  # Just in case the math is off
143
- approximate_pending_messages > 0
139
+ approximate_pending_messages.positive?
144
140
  end
145
141
 
146
142
  def transmit(message, raw_message, dispatch_options = {})
@@ -182,15 +178,15 @@ module HermesMessengerOfTheGods
182
178
  end
183
179
 
184
180
  def set_message_visibility(messages, new_time)
185
- queue.change_message_visibility_batch(
186
- entries: messages.collect do |message|
187
- {
188
- id: SecureRandom.uuid,
189
- receipt_handle: message.receipt_handle,
190
- visibility_timeout: new_time
191
- }
192
- end
193
- )
181
+ payload = messages.collect do |message|
182
+ {
183
+ id: SecureRandom.uuid,
184
+ receipt_handle: message.receipt_handle,
185
+ visibility_timeout: new_time,
186
+ }
187
+ end
188
+
189
+ queue.change_message_visibility_batch(entries: payload)
194
190
  end
195
191
  end
196
192
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'hermes_messenger_of_the_gods/endpoints/base'
2
4
  require 'hermes_messenger_of_the_gods/endpoints/sns'
3
5
  require 'hermes_messenger_of_the_gods/endpoints/sqs'
@@ -18,6 +18,7 @@ module HermesMessengerOfTheGods
18
18
  class MessageDispatchFailed < StandardError
19
19
  attr_accessor :exceptions
20
20
  end
21
+
21
22
  class MessageDispatchTotalFailure < MessageDispatchFailed; end
22
23
  class MessageDispatchPartialFailure < MessageDispatchFailed; end
23
24
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
 
3
5
  module HermesMessengerOfTheGods
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Worker Output
2
4
  module HermesMessengerOfTheGods
3
5
  module Output
@@ -5,7 +7,7 @@ module HermesMessengerOfTheGods
5
7
  @subscriptions = []
6
8
 
7
9
  def self.unsubscribe!
8
- @subscriptions.map{|s|ActiveSupport::Notifications.unsubscribe(s) }
10
+ @subscriptions.map { |s| ActiveSupport::Notifications.unsubscribe(s) }
9
11
  end
10
12
 
11
13
  def self.subscribe!
@@ -13,7 +15,7 @@ module HermesMessengerOfTheGods
13
15
 
14
16
  @subscriptions = [
15
17
  ActiveSupport::Notifications.subscribe('hermes_messenger_of_the_gods.worker.starting') do |*_, payload|
16
- payload[:worker].say_info { "Starting Worker" }
18
+ payload[:worker].say_info { 'Starting Worker' }
17
19
  end,
18
20
  ActiveSupport::Notifications.subscribe('hermes_messenger_of_the_gods.worker.run_job') do |_, start, finish, _, payload|
19
21
  payload[:worker].say_debug { "Completed #{to_log_s(payload[:job])} in #{finish - start}s" }
@@ -26,7 +28,7 @@ module HermesMessengerOfTheGods
26
28
  end,
27
29
  ActiveSupport::Notifications.subscribe('hermes_messenger_of_the_gods.worker.failure') do |*_, payload|
28
30
  payload[:worker].say_error { "Error in #{to_log_s(payload[:job])}: #{payload[:error].message}" }
29
- payload[:worker].say_debug { "backtrace: #{payload[:error].backtrace}" }
31
+ payload[:worker].say_debug { "backtrace: #{payload[:error].backtrace}" }
30
32
  end,
31
33
  ActiveSupport::Notifications.subscribe('hermes_messenger_of_the_gods.worker.fatal_error') do |*_, payload|
32
34
  payload[:worker].say_error { "Fatal Error: #{to_log_s(payload[:job])}: #{payload[:exception].message}" }
@@ -34,19 +36,19 @@ module HermesMessengerOfTheGods
34
36
  end,
35
37
  # Message Output
36
38
  ActiveSupport::Notifications.subscribe('hermes_messenger_of_the_gods.message.dispatch') do |_, _start, _finish, _, payload|
37
- payload[:message].say_info { "Dispatch complete in #{to_log_s(payload[:job])}s" }
39
+ payload[:message].say_debug { "Dispatch complete in #{to_log_s(payload[:job])}s" }
38
40
  end,
39
41
  ActiveSupport::Notifications.subscribe('hermes_messenger_of_the_gods.message.dispatch_failure') do |*_, payload|
40
- payload[:message].say_debug { "Dispatch failure to #{to_log_s(payload[:job])}: #{payload[:exception].inspect}" }
42
+ payload[:message].say_error { "Dispatch failure to #{to_log_s(payload[:job])}: #{payload[:exception].inspect}" }
41
43
  end,
42
44
  # Endpoint Output
43
45
  ActiveSupport::Notifications.subscribe('hermes_messenger_of_the_gods.endpoint.dispatch') do |_, start, finish, _, payload|
44
- payload[:endpoint].say_info { "Dispatch complete in #{finish - start}s #{" FAILED" if payload.has_key?(:exception)}" }
46
+ payload[:endpoint].say_debug { "Dispatch complete in #{finish - start}s #{' FAILED' if payload.key?(:exception)}" }
45
47
  end,
46
48
  ActiveSupport::Notifications.subscribe(/hermes_messenger_of_the_gods.endpoint.(dispatch|final)_failure/) do |name, *_, payload|
47
- payload[:endpoint].say_debug { "Dispatch #{"final " if name.include?('final_')} failure ##{payload[:try]} to #{payload[:endpoint_name]}: #{payload[:exception].inspect}" }
49
+ payload[:endpoint].say_error { "Dispatch #{'final ' if name.include?('final_')} failure ##{payload[:try]} to #{payload[:endpoint_name]}: #{payload[:exception].inspect}" }
48
50
  end,
49
- ActiveSupport::Notifications.subscribe(/hermes_messenger_of_the_gods.endpoint.read_failure/) do |name, *_, payload|
51
+ ActiveSupport::Notifications.subscribe(/hermes_messenger_of_the_gods.endpoint.read_failure/) do |_name, *_, payload|
50
52
  payload[:endpoint].say_error { "A message was received that could not be decoded: #{payload[:exception].message}" }
51
53
  end,
52
54
  ]
@@ -54,9 +56,11 @@ module HermesMessengerOfTheGods
54
56
  subscribe!
55
57
 
56
58
  def self.to_log_s(item)
57
- item.respond_to?(:to_log_s) ?
58
- item.to_log_s :
59
+ if item.respond_to?(:to_log_s)
60
+ item.to_log_s
61
+ else
59
62
  item.inspect
63
+ end
60
64
  end
61
65
  end
62
66
  end
@@ -9,6 +9,7 @@ module HermesMessengerOfTheGods
9
9
  end
10
10
 
11
11
  attr_accessor :worker, :port
12
+
12
13
  def initialize(worker:, port: nil)
13
14
  self.worker = worker
14
15
  self.port = port || ENV.fetch('HERMES_WORKER_STATUS_PORT', 4242).to_i
@@ -33,7 +33,7 @@ module HermesMessengerOfTheGods
33
33
  pub_opts = fetch_option(:publish_options, raw_message) || {}
34
34
  new_msg = { message: msg, options: opts.merge(pub_opts) }
35
35
  received << new_msg
36
- on_receive.call(new_msg) if on_receive
36
+ on_receive&.call(new_msg)
37
37
  "Recorded msg ##{self.class.received[endpoint].length} for #{endpoint}"
38
38
  end
39
39
  end
@@ -19,14 +19,14 @@ RSpec::Matchers.define :dispatch do |message|
19
19
  proc.call
20
20
  wait_for_async_dispatches
21
21
 
22
- !!@endpoint.received.detect do |m|
22
+ !@endpoint.received.detect do |m|
23
23
  a_hash_including(message).matches?(m[:message]) && (
24
24
  @options.nil? ||
25
25
  a_hash_including(@options).matches?(m[:options])
26
26
  ) && (
27
27
  @message_attributes.nil? || a_hash_including(@message_attributes).matches?(m[:options][:message_attributes])
28
28
  )
29
- end
29
+ end.nil?
30
30
  end
31
31
 
32
32
  chain :to_endpoint do |ep|
@@ -41,7 +41,6 @@ RSpec::Matchers.define :dispatch do |message|
41
41
  @message_attributes = attributes
42
42
  end
43
43
 
44
-
45
44
  failure_message do |_actual|
46
45
  if @matched_early
47
46
  "endpoint already received message that matched: #{message} - message that matched: #{@matched_early}"
@@ -18,16 +18,19 @@ module HermesMessengerOfTheGods
18
18
  def fake_endpoint(type, endpoint, *args)
19
19
  klass = "HermesMessengerOfTheGods::Endpoints::#{type.to_s.camelize}".constantize
20
20
 
21
- build_fake_endpoint(klass, endpoint, *args).tap do |build_ep|
22
- allow(HermesMessengerOfTheGods::EndpointBuilder).to receive(:build)
23
- .with(anything, klass, endpoint, any_args).and_return(build_ep)
21
+ allow(HermesMessengerOfTheGods::EndpointBuilder).to receive(:build)
22
+ .with(anything, klass, endpoint, any_args) do |_, _, _, *new_args|
23
+ build_fake_endpoint(klass, endpoint, *new_args)
24
24
  end
25
+
26
+ build_fake_endpoint(klass, endpoint, *args)
25
27
  end
26
28
 
27
29
  def build_fake_endpoint(klass, endpoint, *args)
28
30
  endpoint = endpoint.to_s
29
- raise "Endpoint required" if endpoint == ''
30
- mock_endpoints[klass][endpoint].options.merge!(*args) if mock_endpoints[klass][endpoint]
31
+ raise 'Endpoint required' if endpoint == ''
32
+
33
+ mock_endpoints[klass][endpoint]&.options&.merge!(*args)
31
34
  mock_endpoints[klass][endpoint] ||= Endpoints::Local.new(endpoint, "#{klass}::#{endpoint}", *args)
32
35
  mock_endpoints[klass][endpoint]
33
36
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module HermesMessengerOfTheGods
2
- VERSION = '2.4.0.pre2'
4
+ VERSION = '2.4.2'
3
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hermes_messenger_of_the_gods
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0.pre2
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Malinconico
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-08-17 00:00:00.000000000 Z
12
+ date: 2023-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -68,7 +68,7 @@ dependencies:
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1.0'
70
70
  - !ruby/object:Gem::Dependency
71
- name: thor
71
+ name: rexml
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
@@ -82,7 +82,7 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
- name: rexml
85
+ name: thor
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
@@ -165,6 +165,20 @@ dependencies:
165
165
  - - "~>"
166
166
  - !ruby/object:Gem::Version
167
167
  version: '3.0'
168
+ - !ruby/object:Gem::Dependency
169
+ name: rubocop
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ type: :development
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
168
182
  - !ruby/object:Gem::Dependency
169
183
  name: timecop
170
184
  requirement: !ruby/object:Gem::Requirement
@@ -191,6 +205,7 @@ files:
191
205
  - ".github/workflows/test.yml"
192
206
  - ".gitignore"
193
207
  - ".rspec"
208
+ - ".rubocop.yml"
194
209
  - ".ruby-version"
195
210
  - ".travis.yml"
196
211
  - CHANGELOG.md
@@ -222,41 +237,6 @@ files:
222
237
  - lib/hermes_messenger_of_the_gods/testing/rspec_helpers.rb
223
238
  - lib/hermes_messenger_of_the_gods/version.rb
224
239
  - packageGems.sh
225
- - vendor/cache/addressable-2.8.0.gem
226
- - vendor/cache/aws-eventstream-1.2.0.gem
227
- - vendor/cache/codeclimate-test-reporter-1.0.7.gem
228
- - vendor/cache/coderay-1.1.3.gem
229
- - vendor/cache/coveralls_reborn-0.22.0.gem
230
- - vendor/cache/crack-0.4.5.gem
231
- - vendor/cache/diff-lcs-1.4.4.gem
232
- - vendor/cache/docile-1.4.0.gem
233
- - vendor/cache/google-protobuf-3.18.0-universal-darwin.gem
234
- - vendor/cache/google-protobuf-3.18.0-x86_64-linux.gem
235
- - vendor/cache/googleapis-common-protos-types-1.2.0.gem
236
- - vendor/cache/grpc-1.40.0-universal-darwin.gem
237
- - vendor/cache/grpc-1.40.0-x86_64-linux.gem
238
- - vendor/cache/hashdiff-1.0.1.gem
239
- - vendor/cache/memory_profiler-1.0.0.gem
240
- - vendor/cache/method_source-1.0.0.gem
241
- - vendor/cache/pry-0.14.1.gem
242
- - vendor/cache/public_suffix-4.0.6.gem
243
- - vendor/cache/rake-10.5.0.gem
244
- - vendor/cache/rexml-3.2.5.gem
245
- - vendor/cache/rspec-3.10.0.gem
246
- - vendor/cache/rspec-core-3.10.1.gem
247
- - vendor/cache/rspec-expectations-3.10.1.gem
248
- - vendor/cache/rspec-mocks-3.10.2.gem
249
- - vendor/cache/rspec-support-3.10.2.gem
250
- - vendor/cache/simplecov-0.21.2.gem
251
- - vendor/cache/simplecov-html-0.12.3.gem
252
- - vendor/cache/simplecov-lcov-0.8.0.gem
253
- - vendor/cache/simplecov_json_formatter-0.1.3.gem
254
- - vendor/cache/sync-0.5.0.gem
255
- - vendor/cache/term-ansicolor-1.7.1.gem
256
- - vendor/cache/thor-1.1.0.gem
257
- - vendor/cache/timecop-0.9.4.gem
258
- - vendor/cache/tins-1.29.1.gem
259
- - vendor/cache/webmock-3.14.0.gem
260
240
  homepage:
261
241
  licenses: []
262
242
  metadata:
@@ -272,9 +252,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
272
252
  version: '0'
273
253
  required_rubygems_version: !ruby/object:Gem::Requirement
274
254
  requirements:
275
- - - ">"
255
+ - - ">="
276
256
  - !ruby/object:Gem::Version
277
- version: 1.3.1
257
+ version: '0'
278
258
  requirements: []
279
259
  rubygems_version: 3.2.22
280
260
  signing_key:
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file