hermes_messenger_of_the_gods 2.2.0 → 2.3.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f14fead382b4de9c274888ee9c417f5b7e500846e118b9e655af25b182164184
|
4
|
+
data.tar.gz: 47edc08f7f760c868ae6c2e2443d4f7138ce23c4b260ae9a288e2b1c5d73f4a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daf9a9781dae2a7243c5b98f06d4a929526c2430d29e52a328d5a94c045a7e016c59844dbf72eed9d773da91f396e0c51efc5d1af6d307b69f2d8940af36084e
|
7
|
+
data.tar.gz: 2e6e02d9a36ce06a0df77e7b732fafbb023cad0e3b0a33e107522b7d798ed9363e655e9c96da92c5a9af2f4961cfe460f33e6771a4bea671fa7998c9d1967801
|
@@ -14,7 +14,7 @@ module HermesMessengerOfTheGods
|
|
14
14
|
super
|
15
15
|
@message_mux = Monitor.new
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def poller
|
19
19
|
@poller ||= Aws::SQS::QueuePoller.new(endpoint)
|
20
20
|
end
|
@@ -33,11 +33,12 @@ module HermesMessengerOfTheGods
|
|
33
33
|
|
34
34
|
# Basic Shutdown behavior:
|
35
35
|
# Allow in-progress message to finish working.
|
36
|
-
# Reset visbility timeout to all un-executed messages (from current message to end of array) to 0 so they move
|
36
|
+
# Reset visbility timeout to all un-executed messages (from current message to end of array) to 0 so they move
|
37
37
|
# to other works
|
38
38
|
#
|
39
39
|
# Break from polling
|
40
40
|
def shutdown!
|
41
|
+
say Logger::INFO, 'Shutdown command received'
|
41
42
|
@shutdown = true
|
42
43
|
end
|
43
44
|
|
@@ -46,7 +47,7 @@ module HermesMessengerOfTheGods
|
|
46
47
|
end
|
47
48
|
|
48
49
|
def work_off(&blk)
|
49
|
-
poller.before_request { |
|
50
|
+
poller.before_request { |_stats| throw :stop_polling if shutting_down? }
|
50
51
|
|
51
52
|
poller.poll(poll_options) do |messages, _stats|
|
52
53
|
self.inflight_messages = messages = Array.wrap(messages)
|
@@ -60,11 +61,12 @@ module HermesMessengerOfTheGods
|
|
60
61
|
# Work message returns true if the messager should be considered successful
|
61
62
|
shutting_down? ? :shutdown : work_message(msg, &blk)
|
62
63
|
end
|
63
|
-
|
64
|
+
|
64
65
|
poller.delete_messages(completion_results[true]) unless completion_results.fetch(true, []).empty?
|
65
66
|
# Messages skipped due to shutdowns get their visibility set back to 0 so they restart
|
66
67
|
# normal failed jobs will be left in queue until their visibility timeout expires to indicate a backoff
|
67
|
-
set_message_visibility(completion_results[:shutdown], 0) unless completion_results.fetch(:shutdown,
|
68
|
+
set_message_visibility(completion_results[:shutdown], 0) unless completion_results.fetch(:shutdown,
|
69
|
+
[]).empty?
|
68
70
|
end
|
69
71
|
end
|
70
72
|
end
|
@@ -94,9 +96,9 @@ module HermesMessengerOfTheGods
|
|
94
96
|
def has_pending_work?
|
95
97
|
data = queue_data.attributes
|
96
98
|
|
97
|
-
approximate_pending_messages = data[
|
98
|
-
|
99
|
-
|
99
|
+
approximate_pending_messages = data['ApproximateNumberOfMessages'].to_i -
|
100
|
+
data['ApproximateNumberOfMessagesNotVisible'].to_i -
|
101
|
+
data['ApproximateNumberOfMessagesDelayed'].to_i
|
100
102
|
|
101
103
|
# Just in case the math is off
|
102
104
|
approximate_pending_messages > 0
|
@@ -132,16 +134,14 @@ module HermesMessengerOfTheGods
|
|
132
134
|
set_message_visibility(inflight_messages, new_time)
|
133
135
|
sleep VISIBILITY_EXTEND_FREQUENCY
|
134
136
|
rescue StandardError => e
|
135
|
-
|
136
|
-
|
137
|
+
warn 'Error received trying to extend visibility'
|
138
|
+
warn e.message
|
137
139
|
|
138
140
|
raise
|
139
141
|
end
|
140
142
|
end
|
141
143
|
end
|
142
144
|
|
143
|
-
private
|
144
|
-
|
145
145
|
def set_message_visibility(messages, new_time)
|
146
146
|
queue.change_message_visibility_batch(
|
147
147
|
entries: messages.collect do |message|
|
@@ -15,6 +15,8 @@ module HermesMessengerOfTheGods
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
attr_accessor :on_receive
|
19
|
+
|
18
20
|
def received
|
19
21
|
self.class.received[endpoint]
|
20
22
|
end
|
@@ -29,7 +31,9 @@ module HermesMessengerOfTheGods
|
|
29
31
|
|
30
32
|
def do_transmit(msg, opts, raw_message = {})
|
31
33
|
pub_opts = fetch_option(:publish_options, raw_message) || {}
|
32
|
-
|
34
|
+
new_msg = { message: msg, options: opts.merge(pub_opts) }
|
35
|
+
received << new_msg
|
36
|
+
on_receive.call(new_msg) if on_receive
|
33
37
|
"Recorded msg ##{self.class.received[endpoint].length} for #{endpoint}"
|
34
38
|
end
|
35
39
|
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
|
+
version: 2.3.0
|
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: 2022-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|