rafka 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -0
- data/lib/rafka.rb +23 -0
- data/lib/rafka/consumer.rb +5 -2
- data/lib/rafka/producer.rb +7 -3
- data/lib/rafka/version.rb +1 -1
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f4b1340d7d6aed3fc3151f8655993b1a197016be9dd8537856118fca48d305bb
|
4
|
+
data.tar.gz: 4741170487839f7087b9637e7473a7ac4e005e339c34ef9886aabd984873afe5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1c285aae295bb0c5b0f575116ba2734f57b2117b3555ba272d97a18ea8bde86ecde1d1308063d3310b351657b4e6f70514bca9842498ed92717254ce0c6daad
|
7
|
+
data.tar.gz: 0a69e03ccc7344446f3f77c239d43a99c6d5e19567a4833ef0458cf13a82497ba4e67c6935698ba99c9764dfc42e133e0173d867114228d54c1768a543d56679
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@ Breaking changes are prefixed with a "[BREAKING]" label.
|
|
4
4
|
|
5
5
|
## master (unreleased)
|
6
6
|
|
7
|
+
## 0.5.0 (2019-10-09)
|
8
|
+
|
9
|
+
## Changed
|
10
|
+
|
11
|
+
- Consumer operations are now restarted upon `Rafka::ConsumeError: Server shutdown` exceptions (i.e. during server restarts) [[#27](https://github.com/skroutz/rafka-rb/pull/27)]
|
7
12
|
|
8
13
|
## 0.4.1 (2018-23-05)
|
9
14
|
|
data/lib/rafka.rb
CHANGED
@@ -14,6 +14,12 @@ module Rafka
|
|
14
14
|
port: 6380
|
15
15
|
}.freeze
|
16
16
|
|
17
|
+
# Server errors upon which we should retry the operation.
|
18
|
+
RETRIABLE_ERRORS = [
|
19
|
+
"CONS Server shutdown"
|
20
|
+
].freeze
|
21
|
+
|
22
|
+
# Wraps errors from redis-rb to our own error classes
|
17
23
|
def self.wrap_errors
|
18
24
|
yield
|
19
25
|
rescue Redis::CommandError => e
|
@@ -21,4 +27,21 @@ module Rafka
|
|
21
27
|
raise ConsumeError, e.message[5..-1] if e.message.start_with?("CONS ")
|
22
28
|
raise CommandError, e.message
|
23
29
|
end
|
30
|
+
|
31
|
+
# Retries the operation upon Redis::CommandError
|
32
|
+
def self.with_retry(max_retries=15)
|
33
|
+
retries = 0
|
34
|
+
|
35
|
+
begin
|
36
|
+
yield
|
37
|
+
rescue Redis::CommandError => e
|
38
|
+
if RETRIABLE_ERRORS.include?(e.message) && retries < max_retries
|
39
|
+
sleep 1
|
40
|
+
retries += 1
|
41
|
+
retry
|
42
|
+
end
|
43
|
+
|
44
|
+
raise e
|
45
|
+
end
|
46
|
+
end
|
24
47
|
end
|
data/lib/rafka/consumer.rb
CHANGED
@@ -61,7 +61,8 @@ module Rafka
|
|
61
61
|
# {#commit}.
|
62
62
|
#
|
63
63
|
# @param timeout [Fixnum] the time in seconds to wait for a message. If
|
64
|
-
# reached, {#consume} returns nil.
|
64
|
+
# reached, {#consume} returns nil. Must be smaller than or equal to the underlying Redis client's
|
65
|
+
# `read_timeout` which superseeds the current timeout.
|
65
66
|
#
|
66
67
|
# @yieldparam [Message] msg the consumed message
|
67
68
|
#
|
@@ -239,7 +240,9 @@ module Rafka
|
|
239
240
|
msg = nil
|
240
241
|
|
241
242
|
Rafka.wrap_errors do
|
242
|
-
|
243
|
+
Rafka.with_retry do
|
244
|
+
msg = @redis.blpop(@blpop_arg, timeout: timeout)
|
245
|
+
end
|
243
246
|
end
|
244
247
|
|
245
248
|
msg = Message.new(msg) if msg
|
data/lib/rafka/producer.rb
CHANGED
@@ -46,10 +46,14 @@ module Rafka
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
# Flush any
|
50
|
-
#
|
49
|
+
# Flush any outstanding messages. The server will block until all messages
|
50
|
+
# are written or the provided timeout is exceeded. Note however, that the
|
51
|
+
# provided timeout may be overshot by the `read_timeout` setting of the
|
52
|
+
# underlying Redis client. This means that the client might interrupt the
|
53
|
+
# call earlier than timeout_ms, if `read_timeout` is less than `timeout_ms`.
|
51
54
|
#
|
52
|
-
# @param timeout_ms [Fixnum]
|
55
|
+
# @param timeout_ms [Fixnum]. Must be smaller than or equal to the underlying Redis client's `read_timeout`
|
56
|
+
# which superseeds the current timeout.
|
53
57
|
#
|
54
58
|
# @return [Fixnum] The number of unflushed messages
|
55
59
|
def flush(timeout_ms=5000)
|
data/lib/rafka/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rafka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agis Anastasopoulos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: redis
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.3.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.3.2
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: minitest
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,8 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
132
|
- !ruby/object:Gem::Version
|
119
133
|
version: '0'
|
120
134
|
requirements: []
|
121
|
-
|
122
|
-
rubygems_version: 2.5.2.3
|
135
|
+
rubygems_version: 3.0.4
|
123
136
|
signing_key:
|
124
137
|
specification_version: 4
|
125
138
|
summary: Ruby driver for Rafka
|