sqewer 6.0.6 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -2
- data/lib/sqewer/connection.rb +2 -2
- data/lib/sqewer/extensions/appsignal_wrapper.rb +4 -2
- data/lib/sqewer/middleware_stack.rb +2 -2
- data/lib/sqewer/submitter.rb +2 -0
- data/lib/sqewer/version.rb +1 -1
- data/lib/sqewer/worker.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1301945308afd9596e1b563dd0ed568f8dd2bd82
|
4
|
+
data.tar.gz: 770c8114bf9ef3bc84b96dcfb6a08fb251d77643
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdcd703b863c6e5ce2af7adeaf4a6205304d7c42ed0a227dc7d466c270294013efba20d7f2030c644663c6f6a6c98549b364802eeb407664e646056fa9d7adbe
|
7
|
+
data.tar.gz: 408b96e763f411673b914011cb5f70dfde2b791da07a4487f3b018d5dad8ae1b1f01a83cc0a5cf182ec7852672dfadb97a46c92a34e0007e47aa22a5b6673b2f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
### 6.1.0
|
2
|
+
- Pass SQS message attributes through the middleware chain
|
3
|
+
- Recover the SentTimestamp attribute and set it as queue start in Appsignal
|
4
|
+
- Make sure a job given to `submit!` responds to `run`
|
5
|
+
|
1
6
|
### 6.0.6
|
2
7
|
- Make sure :sqewer ActiveJob adapter parameter works in both Rails 4
|
3
8
|
and Rails 5.
|
data/README.md
CHANGED
@@ -248,8 +248,8 @@ You can wrap job processing in middleware. A full-featured middleware class look
|
|
248
248
|
|
249
249
|
class MyWrapper
|
250
250
|
# Surrounds the job instantiation from the string coming from SQS.
|
251
|
-
def around_deserialization(serializer, msg_id, msg_payload)
|
252
|
-
# msg_id is the receipt handle, msg_payload is the message body string
|
251
|
+
def around_deserialization(serializer, msg_id, msg_payload, msg_attributes)
|
252
|
+
# msg_id is the receipt handle, msg_payload is the message body string, msg_attributes are the message's attributes
|
253
253
|
yield
|
254
254
|
end
|
255
255
|
|
data/lib/sqewer/connection.rb
CHANGED
@@ -14,7 +14,7 @@ class Sqewer::Connection
|
|
14
14
|
NotOurFaultAwsError = Class.new(StandardError)
|
15
15
|
|
16
16
|
# A wrapper for most important properties of the received message
|
17
|
-
class Message < Struct.new(:receipt_handle, :body)
|
17
|
+
class Message < Struct.new(:receipt_handle, :body, :attributes)
|
18
18
|
def inspect
|
19
19
|
body.inspect
|
20
20
|
end
|
@@ -57,7 +57,7 @@ class Sqewer::Connection
|
|
57
57
|
Retriable.retriable on: Seahorse::Client::NetworkingError, tries: MAX_RANDOM_RECEIVE_FAILURES do
|
58
58
|
response = client.receive_message(queue_url: @queue_url,
|
59
59
|
wait_time_seconds: DEFAULT_TIMEOUT_SECONDS, max_number_of_messages: BATCH_RECEIVE_SIZE)
|
60
|
-
response.messages.map {|message| Message.new(message.receipt_handle, message.body) }
|
60
|
+
response.messages.map {|message| Message.new(message.receipt_handle, message.body, message.attributes) }
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -22,7 +22,7 @@ module Sqewer
|
|
22
22
|
def env; {params: self.params}; end
|
23
23
|
end
|
24
24
|
|
25
|
-
def around_deserialization(serializer, msg_id, msg_payload)
|
25
|
+
def around_deserialization(serializer, msg_id, msg_payload, msg_attributes)
|
26
26
|
return yield unless Appsignal.active?
|
27
27
|
|
28
28
|
# This creates a transaction, but also sets it as the Appsignal.current_transaction
|
@@ -35,7 +35,9 @@ module Sqewer
|
|
35
35
|
|
36
36
|
transaction.set_action('%s#%s' % [serializer.class, 'unserialize'])
|
37
37
|
transaction.request.params = {:sqs_message_body => msg_payload.to_s}
|
38
|
-
|
38
|
+
if msg_attributes.key?('SentTimestamp')
|
39
|
+
transaction.set_queue_start = Time.at(msg_attributes['SentTimestamp'].to_i / 1000.0)
|
40
|
+
end
|
39
41
|
|
40
42
|
job_unserialized = yield
|
41
43
|
|
@@ -33,12 +33,12 @@ class Sqewer::MiddlewareStack
|
|
33
33
|
}.call
|
34
34
|
end
|
35
35
|
|
36
|
-
def around_deserialization(serializer, message_id, message_body, &inner_block)
|
36
|
+
def around_deserialization(serializer, message_id, message_body, message_attributes, &inner_block)
|
37
37
|
return yield if @handlers.empty?
|
38
38
|
|
39
39
|
responders = @handlers.select{|e| e.respond_to?(:around_deserialization) }
|
40
40
|
responders.reverse.inject(inner_block) {|outer_block, middleware_object|
|
41
|
-
->{ middleware_object.public_send(:around_deserialization, serializer, message_id, message_body, &outer_block) }
|
41
|
+
->{ middleware_object.public_send(:around_deserialization, serializer, message_id, message_body, message_attributes, &outer_block) }
|
42
42
|
}.call
|
43
43
|
end
|
44
44
|
end
|
data/lib/sqewer/submitter.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# and the serializer (something that responds to `#serialize`) to
|
4
4
|
# convert the job into the string that will be put in the queue.
|
5
5
|
class Sqewer::Submitter < Struct.new(:connection, :serializer)
|
6
|
+
NotSqewerJob = Class.new(StandardError)
|
6
7
|
|
7
8
|
# Returns a default Submitter, configured with the default connection
|
8
9
|
# and the default serializer.
|
@@ -11,6 +12,7 @@ class Sqewer::Submitter < Struct.new(:connection, :serializer)
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def submit!(job, **kwargs_for_send)
|
15
|
+
raise NotSqewerJob.new("Submitted object is not a valid job: #{job.inspect}") unless job.respond_to?(:run)
|
14
16
|
message_body = if delay_by_seconds = kwargs_for_send[:delay_seconds]
|
15
17
|
clamped_delay = clamp_delay(delay_by_seconds)
|
16
18
|
kwargs_for_send[:delay_seconds] = clamped_delay
|
data/lib/sqewer/version.rb
CHANGED
data/lib/sqewer/worker.rb
CHANGED
@@ -204,7 +204,7 @@ class Sqewer::Worker
|
|
204
204
|
box = Sqewer::ConnectionMessagebox.new(connection)
|
205
205
|
return box.delete_message(message.receipt_handle) unless message.has_body?
|
206
206
|
|
207
|
-
job = middleware_stack.around_deserialization(serializer, message.receipt_handle, message.body) do
|
207
|
+
job = middleware_stack.around_deserialization(serializer, message.receipt_handle, message.body, message.attributes) do
|
208
208
|
serializer.unserialize(message.body)
|
209
209
|
end
|
210
210
|
return unless job
|
@@ -243,7 +243,7 @@ class Sqewer::Worker
|
|
243
243
|
# thread-safe - or at least not it's HTTP client part).
|
244
244
|
box = Sqewer::ConnectionMessagebox.new(connection)
|
245
245
|
|
246
|
-
job = middleware_stack.around_deserialization(serializer, message.receipt_handle, message.body) do
|
246
|
+
job = middleware_stack.around_deserialization(serializer, message.receipt_handle, message.body, message.attributes) do
|
247
247
|
serializer.unserialize(message.body)
|
248
248
|
end
|
249
249
|
return unless job
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqewer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0
|
4
|
+
version: 6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02
|
11
|
+
date: 2019-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-sqs
|