sqrewdriver 0.1.0 → 0.1.1

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: 960177a8b086b8f3a761255650cd099772374d5a775fa0eaddadbc7c11d0a4e6
4
- data.tar.gz: 0a187eac2691915e97ff7fa321aeef27bef3d4b3aeeee11826e310c34108ea71
3
+ metadata.gz: 502c4b11e87ca48df0966e2638a89dcb7295efa9399e4953e039345165e550b3
4
+ data.tar.gz: 6522640879f24a8422dc4e50fe778333bdd0a9d1c74f815932c5446b67cb96f3
5
5
  SHA512:
6
- metadata.gz: f5ffdc6396c6fca90c6c33cb385da8a7df5dff42f536dcf3716bca5733f7b7e1c1ddccbcc4957211666760c837f2550871daec05650558a9cbc917fc036d4fc1
7
- data.tar.gz: 7ffd2951ebf5171c0821dcf1ec71a34a96953d8f3e61f17c92291104aeee33372b9d13c697be7411e30ef22913e99832b563dd2352338a9c3d2164eb44a4e0c1
6
+ metadata.gz: 0c67020f0209e9045497c93e7e023c03df693e55c0a7a40a1785e42e294ae1a025631cbd0981d4ec64a03fd1fb6341bdd676ae0d2a9927b15afcfe1e946a6174
7
+ data.tar.gz: 866c67be25a34ae3a39fb76971bdf4f2e15f313a13a3535e50f05ef682f11d488b94c9d95180fb7dd4bd95ab6f031c35056a1aa27a022a9bf2f21b602fc4316b
data/.travis.yml CHANGED
@@ -3,5 +3,5 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.6.1
6
+ - 2.6.2
7
7
  before_install: gem install bundler -v 2.0.1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sqrewdriver (0.1.0)
4
+ sqrewdriver (0.1.1)
5
5
  aws-sdk-sqs
6
6
  concurrent-ruby
7
7
 
@@ -55,6 +55,10 @@ module Sqrewdriver
55
55
  @data << message
56
56
  @bytesize += size
57
57
  end
58
+
59
+ def size
60
+ @data.size
61
+ end
58
62
  end
59
63
 
60
64
  include MonitorMixin
@@ -77,7 +81,7 @@ module Sqrewdriver
77
81
 
78
82
  synchronize do
79
83
  @chunks << Chunk.new if @chunks.empty?
80
- if @chunks.last.bytesize + add_size > MAX_PAYLOAD_SIZE
84
+ if @chunks.last.size == MAX_BATCH_SIZE || @chunks.last.bytesize + add_size > MAX_PAYLOAD_SIZE
81
85
  new_chunk = Chunk.new
82
86
  new_chunk.add(message, add_size)
83
87
  @chunks << new_chunk
@@ -97,7 +101,7 @@ module Sqrewdriver
97
101
 
98
102
  synchronize do
99
103
  @chunks << Chunk.new if @chunks.empty?
100
- if @chunks.last.bytesize + add_size > MAX_PAYLOAD_SIZE
104
+ if @chunks.last.size == MAX_BATCH_SIZE || @chunks.last.bytesize + add_size > MAX_PAYLOAD_SIZE
101
105
  new_chunk = Chunk.new
102
106
  new_chunk.add(base_message, add_size)
103
107
  @chunks << new_chunk
@@ -171,13 +175,17 @@ module Sqrewdriver
171
175
 
172
176
  def wait_flushing(timeout = nil)
173
177
  zipped = Concurrent::Promises.zip_futures_on(@thread_pool, *@waiting_futures)
174
- exceptions = zipped.reason(timeout)
178
+ unless zipped.wait(timeout)
179
+ raise Sqrewdriver::SendMessageTimeout
180
+ end
181
+
182
+ exceptions = zipped.reason
175
183
  raise Sqrewdriver::SendMessageErrors.new(exceptions) if exceptions
176
184
  end
177
185
 
178
- def flush
186
+ def flush(timeout = nil)
179
187
  flush_async
180
- wait_flushing
188
+ wait_flushing(timeout)
181
189
  end
182
190
 
183
191
  private
@@ -201,7 +209,7 @@ module Sqrewdriver
201
209
  def ensure_serializer_for_aggregation!(serializer)
202
210
  valid_serializer = @aggregate_messages_per.nil? || serializer.is_a?(Sqrewdriver::Serdes::JSONSerde)
203
211
  unless valid_serializer
204
- raise InvalidSerializer, "If you use `aggregate_messages_per`, serializer must be `Oj` or `MultiJson`"
212
+ raise InvalidSerializer, "If you use `aggregate_messages_per`, serializer must be `Sqrewdriver::Serdes::JSONSerde`"
205
213
  end
206
214
  end
207
215
  end
@@ -18,4 +18,6 @@ module Sqrewdriver
18
18
  @failed = failed
19
19
  end
20
20
  end
21
+
22
+ class SendMessageTimeout < StandardError; end
21
23
  end
@@ -1,3 +1,3 @@
1
1
  module Sqrewdriver
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqrewdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - joker1007
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-29 00:00:00.000000000 Z
11
+ date: 2019-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-sqs