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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -1
- data/.rubocop.yml +7 -0
- data/Gemfile +4 -2
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/exe/fly_hermes +6 -11
- data/hermes_messenger_of_the_gods.gemspec +2 -1
- data/lib/hermes_messenger_of_the_gods/concerns/base.rb +1 -1
- data/lib/hermes_messenger_of_the_gods/concerns/grpc_protobuf.rb +1 -4
- data/lib/hermes_messenger_of_the_gods/concerns/message.rb +1 -3
- data/lib/hermes_messenger_of_the_gods/concerns/worker.rb +3 -1
- data/lib/hermes_messenger_of_the_gods/configuration.rb +4 -2
- data/lib/hermes_messenger_of_the_gods/endpoint_builder.rb +9 -3
- data/lib/hermes_messenger_of_the_gods/endpoints/base.rb +5 -3
- data/lib/hermes_messenger_of_the_gods/endpoints/sns.rb +1 -1
- data/lib/hermes_messenger_of_the_gods/endpoints/sqs.rb +16 -20
- data/lib/hermes_messenger_of_the_gods/endpoints.rb +2 -0
- data/lib/hermes_messenger_of_the_gods/exceptions.rb +1 -0
- data/lib/hermes_messenger_of_the_gods/logging_helpers.rb +2 -0
- data/lib/hermes_messenger_of_the_gods/output/basic.rb +14 -10
- data/lib/hermes_messenger_of_the_gods/status_server.rb +1 -0
- data/lib/hermes_messenger_of_the_gods/testing/array_endpoint.rb +1 -1
- data/lib/hermes_messenger_of_the_gods/testing/dispatch_matcher.rb +2 -3
- data/lib/hermes_messenger_of_the_gods/testing/rspec_helpers.rb +8 -5
- data/lib/hermes_messenger_of_the_gods/version.rb +3 -1
- metadata +21 -41
- data/vendor/cache/addressable-2.8.0.gem +0 -0
- data/vendor/cache/aws-eventstream-1.2.0.gem +0 -0
- data/vendor/cache/codeclimate-test-reporter-1.0.7.gem +0 -0
- data/vendor/cache/coderay-1.1.3.gem +0 -0
- data/vendor/cache/coveralls_reborn-0.22.0.gem +0 -0
- data/vendor/cache/crack-0.4.5.gem +0 -0
- data/vendor/cache/diff-lcs-1.4.4.gem +0 -0
- data/vendor/cache/docile-1.4.0.gem +0 -0
- data/vendor/cache/google-protobuf-3.18.0-universal-darwin.gem +0 -0
- data/vendor/cache/google-protobuf-3.18.0-x86_64-linux.gem +0 -0
- data/vendor/cache/googleapis-common-protos-types-1.2.0.gem +0 -0
- data/vendor/cache/grpc-1.40.0-universal-darwin.gem +0 -0
- data/vendor/cache/grpc-1.40.0-x86_64-linux.gem +0 -0
- data/vendor/cache/hashdiff-1.0.1.gem +0 -0
- data/vendor/cache/memory_profiler-1.0.0.gem +0 -0
- data/vendor/cache/method_source-1.0.0.gem +0 -0
- data/vendor/cache/pry-0.14.1.gem +0 -0
- data/vendor/cache/public_suffix-4.0.6.gem +0 -0
- data/vendor/cache/rake-10.5.0.gem +0 -0
- data/vendor/cache/rexml-3.2.5.gem +0 -0
- data/vendor/cache/rspec-3.10.0.gem +0 -0
- data/vendor/cache/rspec-core-3.10.1.gem +0 -0
- data/vendor/cache/rspec-expectations-3.10.1.gem +0 -0
- data/vendor/cache/rspec-mocks-3.10.2.gem +0 -0
- data/vendor/cache/rspec-support-3.10.2.gem +0 -0
- data/vendor/cache/simplecov-0.21.2.gem +0 -0
- data/vendor/cache/simplecov-html-0.12.3.gem +0 -0
- data/vendor/cache/simplecov-lcov-0.8.0.gem +0 -0
- data/vendor/cache/simplecov_json_formatter-0.1.3.gem +0 -0
- data/vendor/cache/sync-0.5.0.gem +0 -0
- data/vendor/cache/term-ansicolor-1.7.1.gem +0 -0
- data/vendor/cache/thor-1.1.0.gem +0 -0
- data/vendor/cache/timecop-0.9.4.gem +0 -0
- data/vendor/cache/tins-1.29.1.gem +0 -0
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3ad7cd6b63d696cd8e765e69def47efa4496c43e1573b9dc80a966f770df0da
|
4
|
+
data.tar.gz: 627776d0de4ac041fc22b6cb35c3fe2f8ee2d873375599c6136b54d00bc46d29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56035ce71cfc68f0e593a6ffc81236ef8512ab186f459f1b6d29f6322e161862951ba4fe82210cdee8ab189023ef4ef7fd31452f6f4df822be1d39578cfc79e9
|
7
|
+
data.tar.gz: 74a55d8d43193c40f7e0e345a8dfe81fc72c3674202ed29c997259f30acf8ebda468e6b920fe88e8dbc28b5018eabf2e208cf23ae533c5f592442e60c69941af
|
data/.github/workflows/test.yml
CHANGED
data/.rubocop.yml
ADDED
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
|
14
|
+
gem 'webmock'
|
13
15
|
end
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
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
|
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
|
-
|
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
|
-
|
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
|
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
|
@@ -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
|
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
|
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(
|
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
|
-
|
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
|
-
|
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
|
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
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
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
|
# 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 {
|
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].
|
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].
|
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].
|
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].
|
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 |
|
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
|
@@ -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
|
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
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
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
|
30
|
-
|
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
|
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.
|
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:
|
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:
|
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:
|
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:
|
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
|
data/vendor/cache/pry-0.14.1.gem
DELETED
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
|
data/vendor/cache/sync-0.5.0.gem
DELETED
Binary file
|
Binary file
|
data/vendor/cache/thor-1.1.0.gem
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|