sqewer 7.0.0 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/sqewer.rb +2 -16
- data/lib/sqewer/connection.rb +17 -16
- data/lib/sqewer/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bef1bf31a141c142252a3ff3a898351808d378f0538197769091fabcfdf7e0e
|
4
|
+
data.tar.gz: 6eeffee2b8ec4009507ad192aede407c5ab0bb929e694f89f7bf2394ea3f3301
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b7a6faf35f31cc8fa8f33d063964553308cfef543a2e35c26dccfc55e9819a7754eaff9a77c35233d6e230269f2adc06c8ee23902fda5f41e8c4d0708b6ff02
|
7
|
+
data.tar.gz: 9aeedcf29cabcb941037df8c51712d908901ab7700c75649ca40986418fc7462ef17218a7431d798cdf43da6ba545b8e3d87bc56735c34e9dac7181579f63560
|
data/CHANGELOG.md
CHANGED
data/lib/sqewer.rb
CHANGED
@@ -11,23 +11,9 @@ module Sqewer
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
#
|
15
|
-
# We recommend setting the options instance_profile_credentials_timeout and
|
16
|
-
# instance_profile_credentials_retries, for example:
|
17
|
-
#
|
18
|
-
# sqs_client = Aws::SQS::Client.new(
|
19
|
-
# instance_profile_credentials_timeout: 1,
|
20
|
-
# instance_profile_credentials_retries: 5,
|
21
|
-
# )
|
22
|
-
# Storm.client = sqs_client
|
23
|
-
#
|
24
|
-
# @param client[Aws::SQS::Client] an instance of Aws::SQS::Client
|
25
|
-
def self.client=(client)
|
26
|
-
@client = client
|
27
|
-
end
|
28
|
-
|
14
|
+
# Returns a singleton of Aws::SQS::Client
|
29
15
|
def self.client
|
30
|
-
|
16
|
+
Sqewer::Connection.client
|
31
17
|
end
|
32
18
|
|
33
19
|
# Loads a particular Sqewer extension that is not loaded
|
data/lib/sqewer/connection.rb
CHANGED
@@ -39,12 +39,25 @@ class Sqewer::Connection
|
|
39
39
|
raise "SQS_QUEUE_URL not set in the environment. This is the queue URL Sqewer uses by default."
|
40
40
|
end
|
41
41
|
|
42
|
+
# Returns a singleton of Aws::SQS::Client
|
43
|
+
def self.client
|
44
|
+
# It's better using a singleton client to prevent making a lot of HTTP
|
45
|
+
# requests to the AWS metadata endpoint when getting credentials.
|
46
|
+
@client ||= begin
|
47
|
+
require 'aws-sdk-sqs'
|
48
|
+
::Aws::SQS::Client.new(
|
49
|
+
instance_profile_credentials_timeout: 1,
|
50
|
+
instance_profile_credentials_retries: 5,
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
42
55
|
# Initializes a new adapter, with access to the SQS queue at the given URL.
|
43
56
|
#
|
44
57
|
# @param queue_url[String] the SQS queue URL (the URL can be copied from your AWS console)
|
45
|
-
def initialize(queue_url)
|
46
|
-
require 'aws-sdk-sqs'
|
58
|
+
def initialize(queue_url, client: self.class.client)
|
47
59
|
@queue_url = queue_url
|
60
|
+
@client = client
|
48
61
|
end
|
49
62
|
|
50
63
|
# Receive at most 10 messages from the queue, and return the array of Message objects. Retries for at
|
@@ -55,7 +68,7 @@ class Sqewer::Connection
|
|
55
68
|
# @return [Array<Message>] an array of Message objects
|
56
69
|
def receive_messages
|
57
70
|
Retriable.retriable on: network_and_aws_sdk_errors, tries: MAX_RANDOM_RECEIVE_FAILURES do
|
58
|
-
response = client.receive_message(
|
71
|
+
response = @client.receive_message(
|
59
72
|
queue_url: @queue_url,
|
60
73
|
attribute_names: ['All'],
|
61
74
|
wait_time_seconds: DEFAULT_TIMEOUT_SECONDS,
|
@@ -197,7 +210,7 @@ class Sqewer::Connection
|
|
197
210
|
|
198
211
|
def handle_batch_with_retries(method, batch)
|
199
212
|
Retriable.retriable on: network_and_aws_sdk_errors, tries: MAX_RANDOM_FAILURES_PER_CALL do
|
200
|
-
resp = client.send(method, queue_url: @queue_url, entries: batch)
|
213
|
+
resp = @client.send(method, queue_url: @queue_url, entries: batch)
|
201
214
|
wrong_messages, aws_failures = resp.failed.partition {|m| m.sender_fault }
|
202
215
|
if wrong_messages.any?
|
203
216
|
err = wrong_messages.inspect + ', ' + resp.inspect
|
@@ -209,16 +222,4 @@ class Sqewer::Connection
|
|
209
222
|
end
|
210
223
|
end
|
211
224
|
end
|
212
|
-
|
213
|
-
def client
|
214
|
-
# It's better using a singleton client to prevent making a lot of HTTP
|
215
|
-
# requests to the AWS metadata endpoint when getting credentials.
|
216
|
-
# Maybe in the future, we can remove @client and use Storm.client only.
|
217
|
-
return Sqewer.client if Sqewer.client
|
218
|
-
|
219
|
-
@client ||= Aws::SQS::Client.new(
|
220
|
-
instance_profile_credentials_timeout: 1, # defaults to 1 second
|
221
|
-
instance_profile_credentials_retries: 5, # defaults to 0 retries
|
222
|
-
)
|
223
|
-
end
|
224
225
|
end
|
data/lib/sqewer/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqewer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
8
8
|
- Andrei Horak
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk-sqs
|
@@ -271,7 +271,7 @@ homepage: https://github.com/WeTransfer/sqewer
|
|
271
271
|
licenses: []
|
272
272
|
metadata:
|
273
273
|
allowed_push_host: https://rubygems.org
|
274
|
-
post_install_message:
|
274
|
+
post_install_message:
|
275
275
|
rdoc_options: []
|
276
276
|
require_paths:
|
277
277
|
- lib
|
@@ -286,8 +286,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
286
286
|
- !ruby/object:Gem::Version
|
287
287
|
version: '0'
|
288
288
|
requirements: []
|
289
|
-
rubygems_version: 3.
|
290
|
-
signing_key:
|
289
|
+
rubygems_version: 3.1.6
|
290
|
+
signing_key:
|
291
291
|
specification_version: 4
|
292
292
|
summary: Process jobs from SQS
|
293
293
|
test_files: []
|