hermes_messenger_of_the_gods 2.1.1 → 2.2.0
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 -0
- data/.gitignore +1 -0
- data/lib/hermes_messenger_of_the_gods/concerns/worker.rb +3 -0
- data/lib/hermes_messenger_of_the_gods/endpoints/sqs.rb +63 -19
- data/lib/hermes_messenger_of_the_gods/version.rb +1 -1
- data/vendor/cache/aws-partitions-1.509.0.gem +0 -0
- data/vendor/cache/aws-sdk-core-3.121.1.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.38.0-x86_64-linux.gem → grpc-1.40.0-x86_64-linux.gem} +0 -0
- metadata +10 -8
- data/vendor/cache/aws-partitions-1.503.0.gem +0 -0
- data/vendor/cache/aws-sdk-core-3.121.0.gem +0 -0
- data/vendor/cache/google-protobuf-3.17.3-x86_64-linux.gem +0 -0
- data/vendor/cache/googleapis-common-protos-types-1.1.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: eb594dd4aa42c53e4bb9f412dc0870f4de4361843007653f0b00f27d9dabb24b
|
4
|
+
data.tar.gz: 745bb17e713aa8271933429db47198a054f32d494257777b7064227e51ba8850
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 161da7750d743c04bdc0a56be97fea405adeabe0ebb20bd42bd1c1afcebc08fec176309dd73126ca284b389a53ae489e5a8773583a20744b6a4da5a9145643ad
|
7
|
+
data.tar.gz: 477eb8aeb67d6d4011bf59f1fcadb0b9f0f2da98ec9a2b551e420e14f6197185a97e25912f2f6c6dfa1ce4d6f3b6f7709e76f3cb4bc864550b7649dfe9e0379e
|
data/.github/workflows/test.yml
CHANGED
@@ -31,6 +31,7 @@ jobs:
|
|
31
31
|
COVERALLS_NOISY=true bundle exec rspec --color --format documentation;"
|
32
32
|
|
33
33
|
- name: Push Coveralls
|
34
|
+
continue-on-error: true
|
34
35
|
env:
|
35
36
|
TOKEN: ${{ secrets.COVERALLS_TOKEN }}
|
36
37
|
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}
|
data/.gitignore
CHANGED
@@ -32,6 +32,9 @@ module HermesMessengerOfTheGods
|
|
32
32
|
def work_off
|
33
33
|
WorkerStatusServer.start!(worker: self) if health_check_enabled?
|
34
34
|
|
35
|
+
trap(:TERM) { endpoint.shutdown! }
|
36
|
+
trap(:INT) { endpoint.shutdown! }
|
37
|
+
|
35
38
|
instrument(:starting)
|
36
39
|
self.consecutive_failures = 0
|
37
40
|
endpoint.work_off do |job, original_message|
|
@@ -10,21 +10,61 @@ module HermesMessengerOfTheGods
|
|
10
10
|
VISIBILITY_EXTEND_DURATION = 120
|
11
11
|
VISIBILITY_EXTEND_FREQUENCY = 60
|
12
12
|
|
13
|
+
def initialize(*args)
|
14
|
+
super
|
15
|
+
@message_mux = Monitor.new
|
16
|
+
end
|
17
|
+
|
13
18
|
def poller
|
14
19
|
@poller ||= Aws::SQS::QueuePoller.new(endpoint)
|
15
20
|
end
|
16
21
|
|
22
|
+
def inflight_messages
|
23
|
+
@message_mux.synchronize { @inflight_messages ||= [] }
|
24
|
+
end
|
25
|
+
|
26
|
+
def inflight_messages=(val)
|
27
|
+
@message_mux.synchronize { @inflight_messages = val }
|
28
|
+
end
|
29
|
+
|
30
|
+
def shutting_down?
|
31
|
+
@shutdown || false
|
32
|
+
end
|
33
|
+
|
34
|
+
# Basic Shutdown behavior:
|
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
|
37
|
+
# to other works
|
38
|
+
#
|
39
|
+
# Break from polling
|
40
|
+
def shutdown!
|
41
|
+
@shutdown = true
|
42
|
+
end
|
43
|
+
|
17
44
|
def poll_options
|
18
45
|
(options[:poll_options] || {}).merge(skip_delete: true)
|
19
46
|
end
|
20
47
|
|
21
48
|
def work_off(&blk)
|
22
|
-
poller.
|
23
|
-
messages = Array.wrap(messages)
|
49
|
+
poller.before_request { |stats| throw :stop_polling if shutting_down? }
|
24
50
|
|
25
|
-
|
26
|
-
|
27
|
-
|
51
|
+
poller.poll(poll_options) do |messages, _stats|
|
52
|
+
self.inflight_messages = messages = Array.wrap(messages)
|
53
|
+
|
54
|
+
working_messages do
|
55
|
+
completion_results = messages.group_by do |msg|
|
56
|
+
# We return false if we are shutting down so the messages are not deleted.
|
57
|
+
# It is also possible that this process has already releases these SQS messages
|
58
|
+
# back in to the queue so they may be picked up by another process.
|
59
|
+
#
|
60
|
+
# Work message returns true if the messager should be considered successful
|
61
|
+
shutting_down? ? :shutdown : work_message(msg, &blk)
|
62
|
+
end
|
63
|
+
|
64
|
+
poller.delete_messages(completion_results[true]) unless completion_results.fetch(true, []).empty?
|
65
|
+
# Messages skipped due to shutdowns get their visibility set back to 0 so they restart
|
66
|
+
# 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, []).empty?
|
28
68
|
end
|
29
69
|
end
|
30
70
|
end
|
@@ -77,29 +117,19 @@ module HermesMessengerOfTheGods
|
|
77
117
|
message_body
|
78
118
|
end
|
79
119
|
|
80
|
-
def working_messages
|
81
|
-
thread = start_visibility_update_thread
|
82
|
-
|
120
|
+
def working_messages
|
121
|
+
thread = start_visibility_update_thread
|
83
122
|
yield
|
84
123
|
ensure
|
85
124
|
thread&.terminate
|
86
125
|
end
|
87
126
|
|
88
|
-
def start_visibility_update_thread
|
127
|
+
def start_visibility_update_thread
|
89
128
|
start_work_time = Time.now
|
90
129
|
Thread.new do
|
91
130
|
loop do
|
92
131
|
new_time = (Time.now - start_work_time) + VISIBILITY_EXTEND_DURATION
|
93
|
-
|
94
|
-
entries: messages.collect do |message|
|
95
|
-
{
|
96
|
-
id: SecureRandom.uuid,
|
97
|
-
receipt_handle: message.receipt_handle,
|
98
|
-
visibility_timeout: new_time
|
99
|
-
}
|
100
|
-
end
|
101
|
-
)
|
102
|
-
|
132
|
+
set_message_visibility(inflight_messages, new_time)
|
103
133
|
sleep VISIBILITY_EXTEND_FREQUENCY
|
104
134
|
rescue StandardError => e
|
105
135
|
STDERR.puts 'Error received trying to extend visibility'
|
@@ -109,6 +139,20 @@ module HermesMessengerOfTheGods
|
|
109
139
|
end
|
110
140
|
end
|
111
141
|
end
|
142
|
+
|
143
|
+
private
|
144
|
+
|
145
|
+
def set_message_visibility(messages, new_time)
|
146
|
+
queue.change_message_visibility_batch(
|
147
|
+
entries: messages.collect do |message|
|
148
|
+
{
|
149
|
+
id: SecureRandom.uuid,
|
150
|
+
receipt_handle: message.receipt_handle,
|
151
|
+
visibility_timeout: new_time
|
152
|
+
}
|
153
|
+
end
|
154
|
+
)
|
155
|
+
end
|
112
156
|
end
|
113
157
|
end
|
114
158
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
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.2.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: 2021-
|
12
|
+
date: 2021-10-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -226,8 +226,8 @@ files:
|
|
226
226
|
- vendor/cache/activesupport-6.1.4.1.gem
|
227
227
|
- vendor/cache/addressable-2.8.0.gem
|
228
228
|
- vendor/cache/aws-eventstream-1.2.0.gem
|
229
|
-
- vendor/cache/aws-partitions-1.
|
230
|
-
- vendor/cache/aws-sdk-core-3.121.
|
229
|
+
- vendor/cache/aws-partitions-1.509.0.gem
|
230
|
+
- vendor/cache/aws-sdk-core-3.121.1.gem
|
231
231
|
- vendor/cache/aws-sdk-sns-1.45.0.gem
|
232
232
|
- vendor/cache/aws-sdk-sqs-1.44.0.gem
|
233
233
|
- vendor/cache/aws-sigv4-1.4.0.gem
|
@@ -238,9 +238,11 @@ files:
|
|
238
238
|
- vendor/cache/crack-0.4.5.gem
|
239
239
|
- vendor/cache/diff-lcs-1.4.4.gem
|
240
240
|
- vendor/cache/docile-1.4.0.gem
|
241
|
-
- vendor/cache/google-protobuf-3.
|
242
|
-
- vendor/cache/
|
243
|
-
- vendor/cache/
|
241
|
+
- vendor/cache/google-protobuf-3.18.0-universal-darwin.gem
|
242
|
+
- vendor/cache/google-protobuf-3.18.0-x86_64-linux.gem
|
243
|
+
- vendor/cache/googleapis-common-protos-types-1.2.0.gem
|
244
|
+
- vendor/cache/grpc-1.40.0-universal-darwin.gem
|
245
|
+
- vendor/cache/grpc-1.40.0-x86_64-linux.gem
|
244
246
|
- vendor/cache/hashdiff-1.0.1.gem
|
245
247
|
- vendor/cache/i18n-1.8.10.gem
|
246
248
|
- vendor/cache/jmespath-1.4.0.gem
|
@@ -287,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
287
289
|
- !ruby/object:Gem::Version
|
288
290
|
version: '0'
|
289
291
|
requirements: []
|
290
|
-
rubygems_version: 3.2.
|
292
|
+
rubygems_version: 3.2.22
|
291
293
|
signing_key:
|
292
294
|
specification_version: 4
|
293
295
|
summary: Create and receive messages like a god!
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|