karafka 2.1.10 → 2.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +2 -2
- data/config/locales/errors.yml +6 -0
- data/lib/karafka/connection/proxy.rb +31 -25
- data/lib/karafka/contracts/config.rb +16 -0
- data/lib/karafka/setup/config.rb +26 -0
- data/lib/karafka/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d1e3000ced82b96afc7c4588d20170e0908d3b41305eead2e5e0a850c9a70c4
|
4
|
+
data.tar.gz: 1b16fc0a06f1bfd9bdb1207dd1faac04d3a7f956ccb42edd45ada76fed6dcf09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e018450fae0ad666bff80ca9875750303946746c20e527200ee569a1a182c3d81bb71b64a0b2bd94b4a35c8cf204326b26752b1d5c0425a1f544ff9b4572323
|
7
|
+
data.tar.gz: 6025b3583179592313540231dd9d00354c30d8af3d49f482fc6c7dbd96359dbc7bbccee8cfa4cf1d14a2f5dfb3a9999b141317c782ec33af7503c4a8e26c616c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Karafka framework changelog
|
2
2
|
|
3
|
+
## 2.1.11 (2023-08-23)
|
4
|
+
- [Enhancement] Expand the error handling for offset related queries with timeout error retries.
|
5
|
+
- [Enhancement] Allow for connection proxy timeouts configuration.
|
6
|
+
|
3
7
|
## 2.1.10 (2023-08-21)
|
4
8
|
- [Enhancement] Introduce `connection.client.rebalance_callback` event for instrumentation of rebalances.
|
5
9
|
- [Refactor] Introduce low level commands proxy to handle deviation in how we want to run certain commands and how rdkafka-ruby runs that by design.
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
karafka (2.1.
|
4
|
+
karafka (2.1.11)
|
5
5
|
karafka-core (>= 2.1.1, < 2.2.0)
|
6
6
|
thor (>= 0.20)
|
7
7
|
waterdrop (>= 2.6.6, < 3.0.0)
|
@@ -33,7 +33,7 @@ GEM
|
|
33
33
|
karafka-core (2.1.1)
|
34
34
|
concurrent-ruby (>= 1.1)
|
35
35
|
karafka-rdkafka (>= 0.13.1, < 0.14.0)
|
36
|
-
karafka-rdkafka (0.13.
|
36
|
+
karafka-rdkafka (0.13.4)
|
37
37
|
ffi (~> 1.15)
|
38
38
|
mini_portile2 (~> 2.6)
|
39
39
|
rake (> 12)
|
data/config/locales/errors.yml
CHANGED
@@ -26,6 +26,12 @@ en:
|
|
26
26
|
internal.process_format: needs to be present
|
27
27
|
internal.routing.builder_format: needs to be present
|
28
28
|
internal.routing.subscription_groups_builder_format: needs to be present
|
29
|
+
internal.connection.proxy.query_watermark_offsets.timeout_format: needs to be an integer bigger than 0
|
30
|
+
internal.connection.proxy.query_watermark_offsets.max_attempts_format: needs to be an integer bigger than 0
|
31
|
+
internal.connection.proxy.query_watermark_offsets.wait_time_format: needs to be an integer bigger than 0
|
32
|
+
internal.connection.proxy.offsets_for_times.timeout_format: needs to be an integer bigger than 0
|
33
|
+
internal.connection.proxy.offsets_for_times.max_attempts_format: needs to be an integer bigger than 0
|
34
|
+
internal.connection.proxy.offsets_for_times.wait_time_format: needs to be an integer bigger than 0
|
29
35
|
key_must_be_a_symbol: All keys under the kafka settings scope need to be symbols
|
30
36
|
max_timeout_vs_pause_max_timeout: pause_timeout must be less or equal to pause_max_timeout
|
31
37
|
shutdown_timeout_vs_max_wait_time: shutdown_timeout must be more than max_wait_time
|
@@ -10,20 +10,13 @@ module Karafka
|
|
10
10
|
# do still want to be able to alter some functionalities. This wrapper helps us do it when
|
11
11
|
# it would be needed
|
12
12
|
class Proxy < SimpleDelegator
|
13
|
-
#
|
14
|
-
|
13
|
+
# Errors on which we want to retry
|
14
|
+
RETRYABLE_ERRORS = %i[
|
15
|
+
all_brokers_down
|
16
|
+
timed_out
|
17
|
+
].freeze
|
15
18
|
|
16
|
-
|
17
|
-
TPL_REQUEST_TIMEOUT = 5_000
|
18
|
-
|
19
|
-
# How many attempts we want to take for something that would end up with all_brokers_down
|
20
|
-
BROKERS_DOWN_MAX_ATTEMPTS = 3
|
21
|
-
|
22
|
-
# How long should we wait in between all_brokers_down
|
23
|
-
BROKERS_DOWN_BACKOFF_TIME = 1
|
24
|
-
|
25
|
-
private_constant :WATERMARK_REQUEST_TIMEOUT, :BROKERS_DOWN_MAX_ATTEMPTS,
|
26
|
-
:BROKERS_DOWN_BACKOFF_TIME, :TPL_REQUEST_TIMEOUT
|
19
|
+
private_constant :RETRYABLE_ERRORS
|
27
20
|
|
28
21
|
attr_accessor :wrapped
|
29
22
|
|
@@ -36,6 +29,7 @@ module Karafka
|
|
36
29
|
# wrap an already wrapped object with another proxy level. Simplifies passing consumers
|
37
30
|
# and makes it safe to wrap without type checking
|
38
31
|
@wrapped = obj.is_a?(self.class) ? obj.wrapped : obj
|
32
|
+
@config = ::Karafka::App.config.internal.connection.proxy
|
39
33
|
end
|
40
34
|
|
41
35
|
# Proxies the `#query_watermark_offsets` with extra recovery from timeout problems.
|
@@ -46,12 +40,14 @@ module Karafka
|
|
46
40
|
# @param partition [Partition]
|
47
41
|
# @return [Array<Integer, Integer>] watermark offsets
|
48
42
|
def query_watermark_offsets(topic, partition)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
43
|
+
l_config = @config.query_watermark_offsets
|
44
|
+
|
45
|
+
with_broker_errors_retry(
|
46
|
+
# required to be in seconds, not ms
|
47
|
+
wait_time: l_config.wait_time / 1_000.to_f,
|
48
|
+
max_attempts: l_config.max_attempts
|
49
|
+
) do
|
50
|
+
@wrapped.query_watermark_offsets(topic, partition, l_config.timeout)
|
55
51
|
end
|
56
52
|
end
|
57
53
|
|
@@ -61,8 +57,14 @@ module Karafka
|
|
61
57
|
# @param tpl [Rdkafka::Consumer::TopicPartitionList] tpl to get time offsets
|
62
58
|
# @return [Rdkafka::Consumer::TopicPartitionList] tpl with time offsets
|
63
59
|
def offsets_for_times(tpl)
|
64
|
-
|
65
|
-
|
60
|
+
l_config = @config.offsets_for_times
|
61
|
+
|
62
|
+
with_broker_errors_retry(
|
63
|
+
# required to be in seconds, not ms
|
64
|
+
wait_time: l_config.wait_time / 1_000.to_f,
|
65
|
+
max_attempts: l_config.max_attempts
|
66
|
+
) do
|
67
|
+
@wrapped.offsets_for_times(tpl, l_config.timeout)
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
@@ -71,16 +73,20 @@ module Karafka
|
|
71
73
|
# Runs expected block of code with few retries on all_brokers_down
|
72
74
|
# librdkafka can return `all_brokers_down` for scenarios when broker is overloaded or not
|
73
75
|
# reachable due to latency.
|
74
|
-
|
76
|
+
# @param max_attempts [Integer] how many attempts (not retries) should we take before failing
|
77
|
+
# completely.
|
78
|
+
# @param wait_time [Integer, Float] how many seconds should we wait. It uses `#sleep` of Ruby
|
79
|
+
# so it needs time in seconds.
|
80
|
+
def with_broker_errors_retry(max_attempts:, wait_time: 1)
|
75
81
|
attempt ||= 0
|
76
82
|
attempt += 1
|
77
83
|
|
78
84
|
yield
|
79
85
|
rescue Rdkafka::RdkafkaError => e
|
80
|
-
raise
|
86
|
+
raise unless RETRYABLE_ERRORS.include?(e.code)
|
81
87
|
|
82
|
-
if attempt <=
|
83
|
-
sleep(
|
88
|
+
if attempt <= max_attempts
|
89
|
+
sleep(wait_time)
|
84
90
|
|
85
91
|
retry
|
86
92
|
end
|
@@ -39,6 +39,22 @@ module Karafka
|
|
39
39
|
required(:status) { |val| !val.nil? }
|
40
40
|
required(:process) { |val| !val.nil? }
|
41
41
|
|
42
|
+
nested(:connection) do
|
43
|
+
nested(:proxy) do
|
44
|
+
nested(:query_watermark_offsets) do
|
45
|
+
required(:timeout) { |val| val.is_a?(Integer) && val.positive? }
|
46
|
+
required(:max_attempts) { |val| val.is_a?(Integer) && val.positive? }
|
47
|
+
required(:wait_time) { |val| val.is_a?(Integer) && val.positive? }
|
48
|
+
end
|
49
|
+
|
50
|
+
nested(:offsets_for_times) do
|
51
|
+
required(:timeout) { |val| val.is_a?(Integer) && val.positive? }
|
52
|
+
required(:max_attempts) { |val| val.is_a?(Integer) && val.positive? }
|
53
|
+
required(:wait_time) { |val| val.is_a?(Integer) && val.positive? }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
42
58
|
nested(:routing) do
|
43
59
|
required(:builder) { |val| !val.nil? }
|
44
60
|
required(:subscription_groups_builder) { |val| !val.nil? }
|
data/lib/karafka/setup/config.rb
CHANGED
@@ -126,6 +126,32 @@ module Karafka
|
|
126
126
|
setting :activity_manager, default: Routing::ActivityManager.new
|
127
127
|
end
|
128
128
|
|
129
|
+
# Namespace for internal connection related settings
|
130
|
+
setting :connection do
|
131
|
+
# Settings that are altered by our client proxy layer
|
132
|
+
setting :proxy do
|
133
|
+
# Watermark offsets request settings
|
134
|
+
setting :query_watermark_offsets do
|
135
|
+
# timeout for this request. For busy or remote clusters, this should be high enough
|
136
|
+
setting :timeout, default: 5_000
|
137
|
+
# How many times should we try to run this call before raising an error
|
138
|
+
setting :max_attempts, default: 3
|
139
|
+
# How long should we wait before next attempt in case of a failure
|
140
|
+
setting :wait_time, default: 1_000
|
141
|
+
end
|
142
|
+
|
143
|
+
# Offsets for times request settings
|
144
|
+
setting :offsets_for_times do
|
145
|
+
# timeout for this request. For busy or remote clusters, this should be high enough
|
146
|
+
setting :timeout, default: 5_000
|
147
|
+
# How many times should we try to run this call before raising an error
|
148
|
+
setting :max_attempts, default: 3
|
149
|
+
# How long should we wait before next attempt in case of a failure
|
150
|
+
setting :wait_time, default: 1_000
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
129
155
|
setting :processing do
|
130
156
|
# option scheduler [Object] scheduler we will be using
|
131
157
|
setting :scheduler, default: Processing::Scheduler.new
|
data/lib/karafka/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: karafka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej Mensfeld
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
|
36
36
|
msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2023-08-
|
38
|
+
date: 2023-08-23 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: karafka-core
|
metadata.gz.sig
CHANGED
Binary file
|