sqewer 5.0.7 → 5.0.8

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
  SHA1:
3
- metadata.gz: 9dcb51913e099f74dcebca87941f16715b8d3da7
4
- data.tar.gz: e342a210559bf3fb1991b354b764f76adcf64549
3
+ metadata.gz: 303e0674eeb56dc7ff4a8056482a828988eb53c5
4
+ data.tar.gz: 47762bf5591cac2d28a6a6b7078a97c82a697b45
5
5
  SHA512:
6
- metadata.gz: 2be69cb69a9310a1cbfc39f55a709cff854c2638e183d849e6ee9006bcdc922a776af07df97eb333a8beaaf21fc4489479aa0cb4c41136b38d8217e9c6a14159
7
- data.tar.gz: 148aa651f6b73d6ec04c7edd012776c8861d4a187c19529f5fea28c338d056ddcb08411802d5593948496b26419d31b1523295045a6ce9be750c5a4ec25b8253
6
+ metadata.gz: fa6a9832e1833e9ed3ec3b2a316001b4637bc9eeec997474a265aa9242c5b3e490752fa8c12f4d238a5bd6c2ef8a8012ca2e37651d853d4f53b879fc7e253a9e
7
+ data.tar.gz: 10327bbbe1e13113f7ed4910c6feb90f29b1148ee0af9f98762eab127287bfa3038be7609709cd76079efea10038b5d06c25ae9c851c796bfc479947dea33892
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  rvm:
2
- - 2.1.5
3
2
  - 2.2.2
3
+ - 2.3.3
4
+ - 2.4.1
4
5
  sudo: false
5
6
  cache: bundler
6
7
  env:
@@ -8,4 +9,4 @@ env:
8
9
  - secure: E+uNoJmvjq5+3/PYUs2a1bRh7bCjAbcYEIKJzOVgIiI+gWB4dLpTKwVW/fqJbjCDIGPw9OwiwphN51zLEo0ie5AJIkavcjWRcdazKq8usokAz/A5Ilru5YvGXJ5UQtF8TJNsZfJGOGMJwL5d/MsDSd3/sjy88wrFiSeeNlHA06KDBrGdZXE4/dOb5Z84cSxPaD7nDaGP36V3Uv88X272oezODm9Mp+Fsf4goGoU9I9PBDD36pCXAlpURWpyWMKa2TzEX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rEx6MP7xuIM0fjp1oU4cKQe74KX/KuqE=
10
11
  - secure: fWzpY63ZAXOtjEJuYoya/mwzJ7fZQJGsN6hhamXorOhUgaeP2vdC7/6gK3PPMIXOJ5NXPiANGbAUWKgLLWJ3F7rK2y9UCUWTzvE2CK/13vUV9de7byQfAjfHo7wjDJuPLved+WmSM7ASVjzGq9wQS8MTeYUymSNVY3xiZcvNTO2XY9AAu32SSWDs1ayXiCGE9DyN5WEvEEPixHqpplZLvSqTtKtEZVdP/a3tPuzogYFvoJ/ZEfG9LRr4nnbwuKCaTljpYaZc/8yFbhhJgCrTuOKb0gB/UFeMjd0WX6MQWofzIj152d0ghCTlgtESR2LQJdSXA2BO0ZzSqYj8NKTAcZ8IsaUj+6kBgfQGHu43TF/dB877v8pY55HS8a3gFPDK/6OZhRT7UcFZgle1qvX422CD196fRHktSBcDTx9jQsG8r7Ray9oJygXQr6tKhrRkjMkkBAiBd/GkIJkJu5RecmlLOZMJ+YeYa95kWDUXwo3HGK9MxtFyuplSRYk4mQ1jbrJXdmufQuTazl2FYL+elOUeUb8ej3iniUcmyDGU6tZx84aZTbBOaovmeQqr3pXIaXYMhvkRGLD3Ky7SNZN9ZzFczRWcKStyQal+BYK1R3RU8cD0m0PEpUxV5ERP50E3GyN/0d0bg22LywK9aWDHOhCzjI0emVvSAn8ZiY78SSo=
11
- - AWS_REGION=eu-central-1
12
+ - AWS_REGION=eu-central-1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 2017-06-12
2
+ - Released v5.0.8 to Rubygems.org.
3
+ - Retry sending and deleting messages when `sender_fault=false`.
4
+
1
5
  ### 2017-05-26
2
6
  - Released v5.0.7 to Rubygems.org.
3
7
  - Report errors with string interpolation to avoid confusion.
data/lib/sqewer.rb CHANGED
@@ -25,4 +25,7 @@ module Sqewer
25
25
 
26
26
  # If we are within Rails, load the railtie
27
27
  require_relative 'sqewer/extensions/railtie' if defined?(Rails)
28
+
29
+ # Explicitly require retriable so that it ia available for use.
30
+ require 'retriable'
28
31
  end
@@ -8,6 +8,9 @@
8
8
  class Sqewer::Connection
9
9
  DEFAULT_TIMEOUT_SECONDS = 5
10
10
  BATCH_RECEIVE_SIZE = 10
11
+ MAX_RANDOM_FAILURES_PER_CALL = 10
12
+
13
+ NotOurFaultAwsError = Class.new(StandardError)
11
14
 
12
15
  # A wrapper for most important properties of the received message
13
16
  class Message < Struct.new(:receipt_handle, :body)
@@ -96,14 +99,8 @@ class Sqewer::Connection
96
99
  def send_multiple_messages
97
100
  buffer = SendBuffer.new
98
101
  yield(buffer)
99
- buffer.each_batch do | batch |
100
- resp = client.send_message_batch(queue_url: @queue_url, entries: batch)
101
- failed = resp.failed
102
- if failed.any?
103
- err = failed.inspect + ', ' + resp.inspect
104
- raise "#{failed.length} messages failed to send: #{err}"
105
- end
106
- end
102
+
103
+ buffer.each_batch {|batch| handle_batch_with_retries(:send_message_batch, batch) }
107
104
  end
108
105
 
109
106
  # Deletes a message after it has been succesfully decoded and processed
@@ -122,18 +119,26 @@ class Sqewer::Connection
122
119
  buffer = DeleteBuffer.new
123
120
  yield(buffer)
124
121
 
125
- buffer.each_batch do | batch |
126
- resp = client.delete_message_batch(queue_url: @queue_url, entries: batch)
127
- failed = resp.failed
128
- if failed.any?
129
- err = failed.inspect + ', ' + resp.inspect
130
- raise "#{failed.length} messages failed to delete: #{err}"
131
- end
132
- end
122
+ buffer.each_batch {|batch| handle_batch_with_retries(:delete_message_batch, batch) }
133
123
  end
134
124
 
135
125
  private
136
126
 
127
+ def handle_batch_with_retries(method, batch)
128
+ Retriable.retriable on: NotOurFaultAwsError, tries: MAX_RANDOM_FAILURES_PER_CALL do
129
+ resp = client.send(method, queue_url: @queue_url, entries: batch)
130
+ wrong_messages, aws_failures = resp.failed.partition {|m| m.sender_fault }
131
+ if wrong_messages.any?
132
+ err = wrong_messages.inspect + ', ' + resp.inspect
133
+ raise "#{wrong_messages.length} messages failed while doing #{method.to_s} with error: #{err}"
134
+ elsif aws_failures.any?
135
+ # We set the 'batch' param to an array with only the failed messages so only those get retried
136
+ batch = aws_failures.map {|aws_response_message| batch.find { |m| aws_response_message.id.to_s == m[:id] }}
137
+ raise NotOurFaultAwsError
138
+ end
139
+ end
140
+ end
141
+
137
142
  class RetryWrapper < Struct.new(:sqs_client)
138
143
  MAX_RETRIES = 1000
139
144
  # Provide retrying wrappers for all the methods of Aws::SQS::Client that we actually use
@@ -1,3 +1,3 @@
1
1
  module Sqewer
2
- VERSION = '5.0.7'
2
+ VERSION = '5.0.8'
3
3
  end
data/sqewer.gemspec CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_runtime_dependency 'aws-sdk', '~> 2'
33
33
  spec.add_runtime_dependency 'very_tiny_state_machine'
34
34
  spec.add_runtime_dependency 'ks'
35
+ spec.add_runtime_dependency 'retriable'
35
36
 
36
37
  spec.add_development_dependency "bundler", "~> 1"
37
38
  spec.add_development_dependency "rake", "~> 10.0"
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: 5.0.7
4
+ version: 5.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik Tarkhanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-02 00:00:00.000000000 Z
11
+ date: 2017-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: retriable
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -240,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
254
  version: '0'
241
255
  requirements: []
242
256
  rubyforge_project:
243
- rubygems_version: 2.5.2
257
+ rubygems_version: 2.6.11
244
258
  signing_key:
245
259
  specification_version: 4
246
260
  summary: Process jobs from SQS