waterdrop 2.4.3 → 2.4.5
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 +7 -0
- data/Gemfile.lock +1 -1
- data/lib/waterdrop/patches/rdkafka/metadata.rb +37 -0
- data/lib/waterdrop/patches/rdkafka/producer.rb +51 -6
- data/lib/waterdrop/version.rb +1 -1
- data.tar.gz.sig +5 -1
- metadata +3 -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: e1cabe8225d1038bc9fab5c41efaf5822b3d6a633dac233f92058874be8cb5ae
|
4
|
+
data.tar.gz: ac830393a2c6ed2d50042a08fbd59a6d2ebbd0de505a53953c67b3d50ac1dd22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d757751cb8a62fee91c5aff7ac30260e3b45d62d17db71eedcd23b77881b4564b8dc0bef534eb060049a65b5d99610c09c86eeb13913a999d864dffc3adee5e3
|
7
|
+
data.tar.gz: 51cb53cc3a4f168b3157ad840157f2df8a9479381972fe0d8cc13b445449099373acd76d37cf0206ec35d625fb75723b3ab4a3e0c193413de9844c54106209c5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# WaterDrop changelog
|
2
2
|
|
3
|
+
## 2.4.5 (2022-12-10)
|
4
|
+
- Fix invalid error scope visibility.
|
5
|
+
- Cache partition count to improve messages production and lower stress on Kafka when `partition_key` is on.
|
6
|
+
|
7
|
+
## 2.4.4 (2022-12-09)
|
8
|
+
- Add temporary patch on top of `rdkafka-ruby` to mitigate metadata fetch timeout failures.
|
9
|
+
|
3
10
|
## 2.4.3 (2022-12-07)
|
4
11
|
- Support for librdkafka 0.13
|
5
12
|
- Update Github Actions
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WaterDrop
|
4
|
+
# Patches to external components
|
5
|
+
module Patches
|
6
|
+
# Rdkafka related patches
|
7
|
+
module Rdkafka
|
8
|
+
# Rdkafka::Metadata patches
|
9
|
+
module Metadata
|
10
|
+
# We overwrite this method because there were reports of metadata operation timing out
|
11
|
+
# when Kafka was under stress. While the messages dispatch will be retried, metadata
|
12
|
+
# fetch happens prior to that, effectively crashing the process. Metadata fetch was not
|
13
|
+
# being retried at all.
|
14
|
+
#
|
15
|
+
# @param args [Array<Object>] all the metadata original arguments
|
16
|
+
def initialize(*args)
|
17
|
+
attempt ||= 0
|
18
|
+
attempt += 1
|
19
|
+
|
20
|
+
super(*args)
|
21
|
+
rescue ::Rdkafka::RdkafkaError => e
|
22
|
+
raise unless e.code == :timed_out
|
23
|
+
raise if attempt > 10
|
24
|
+
|
25
|
+
backoff_factor = 2**attempt
|
26
|
+
timeout = backoff_factor * 0.1
|
27
|
+
|
28
|
+
sleep(timeout)
|
29
|
+
|
30
|
+
retry
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
::Rdkafka::Metadata.prepend ::WaterDrop::Patches::Rdkafka::Metadata
|
@@ -7,6 +7,25 @@ module WaterDrop
|
|
7
7
|
module Rdkafka
|
8
8
|
# Rdkafka::Producer patches
|
9
9
|
module Producer
|
10
|
+
# Cache partitions count for 30 seconds
|
11
|
+
PARTITIONS_COUNT_TTL = 30_000
|
12
|
+
|
13
|
+
private_constant :PARTITIONS_COUNT_TTL
|
14
|
+
|
15
|
+
# @param args [Object] arguments accepted by the original rdkafka producer
|
16
|
+
def initialize(*args)
|
17
|
+
super
|
18
|
+
|
19
|
+
@_partitions_count_cache = Concurrent::Hash.new do |cache, topic|
|
20
|
+
topic_metadata = ::Rdkafka::Metadata.new(inner_kafka, topic).topics&.first
|
21
|
+
|
22
|
+
cache[topic] = [
|
23
|
+
now,
|
24
|
+
topic_metadata ? topic_metadata[:partition_count] : nil
|
25
|
+
]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
10
29
|
# Adds a method that allows us to get the native kafka producer name
|
11
30
|
#
|
12
31
|
# In between rdkafka versions, there are internal changes that force us to add some extra
|
@@ -14,23 +33,49 @@ module WaterDrop
|
|
14
33
|
#
|
15
34
|
# @return [String] producer instance name
|
16
35
|
def name
|
17
|
-
|
36
|
+
@_name ||= ::Rdkafka::Bindings.rd_kafka_name(inner_kafka)
|
37
|
+
end
|
38
|
+
|
39
|
+
# This patch makes sure we cache the partition count for a given topic for given time
|
40
|
+
# This prevents us in case someone uses `partition_key` from querying for the count with
|
41
|
+
# each message. Instead we query once every 30 seconds at most
|
42
|
+
#
|
43
|
+
# @param topic [String] topic name
|
44
|
+
# @return [Integer] partition count for a given topic
|
45
|
+
def partition_count(topic)
|
46
|
+
closed_producer_check(__method__)
|
47
|
+
|
48
|
+
@_partitions_count_cache.delete_if do |_, cached|
|
49
|
+
now - cached.first > PARTITIONS_COUNT_TTL
|
50
|
+
end
|
51
|
+
|
52
|
+
@_partitions_count_cache[topic].last
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [FFI::Pointer] pointer to the raw librdkafka
|
56
|
+
def inner_kafka
|
57
|
+
unless @_inner_kafka
|
18
58
|
version = ::Gem::Version.new(::Rdkafka::VERSION)
|
19
59
|
|
20
60
|
if version < ::Gem::Version.new('0.12.0')
|
21
|
-
@
|
61
|
+
@_inner_kafka = @native_kafka
|
22
62
|
elsif version < ::Gem::Version.new('0.13.0.beta.1')
|
23
|
-
@
|
63
|
+
@_inner_kafka = @client.native
|
24
64
|
else
|
25
|
-
@
|
65
|
+
@_inner_kafka = @native_kafka.inner
|
26
66
|
end
|
27
67
|
end
|
28
68
|
|
29
|
-
|
69
|
+
@_inner_kafka
|
70
|
+
end
|
71
|
+
|
72
|
+
# @return [Float] current clock time
|
73
|
+
def now
|
74
|
+
::Process.clock_gettime(::Process::CLOCK_MONOTONIC) * 1_000
|
30
75
|
end
|
31
76
|
end
|
32
77
|
end
|
33
78
|
end
|
34
79
|
end
|
35
80
|
|
36
|
-
::Rdkafka::Producer.
|
81
|
+
::Rdkafka::Producer.prepend ::WaterDrop::Patches::Rdkafka::Producer
|
data/lib/waterdrop/version.rb
CHANGED
data.tar.gz.sig
CHANGED
@@ -1 +1,5 @@
|
|
1
|
-
�
|
1
|
+
w�9T���BS�C��=Y<_ʀ����:����-+A�Y���Lo��.}�VNyҙH.�m�Ju�4����\Y2��9�s�]Ї�AԷ[�7�JQ�� 3��]ʳ���Su}"����samB봧�^S����n���K��b�N��F�Ԙ����g��m�,�4r��M�B` �
|
2
|
+
�H>��Kh�*���7��
|
3
|
+
�nA�*�%gOn�z����!CWAP!SҼ8h��n���9z�'�F��j�òr@D�>�V�~�
|
4
|
+
Rj,������и]��cGv���U���2�������L�
|
5
|
+
�r~�3���S`���۹�?�
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waterdrop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej Mensfeld
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
Qf04B9ceLUaC4fPVEz10FyobjaFoY4i32xRto3XnrzeAgfEe4swLq8bQsR3w/EF3
|
36
36
|
MGU0FeSV2Yj7Xc2x/7BzLK8xQn5l7Yy75iPF+KP3vVmDHnNl
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2022-12-
|
38
|
+
date: 2022-12-10 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: karafka-core
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/waterdrop/instrumentation/notifications.rb
|
109
109
|
- lib/waterdrop/instrumentation/vendors/datadog/dashboard.json
|
110
110
|
- lib/waterdrop/instrumentation/vendors/datadog/listener.rb
|
111
|
+
- lib/waterdrop/patches/rdkafka/metadata.rb
|
111
112
|
- lib/waterdrop/patches/rdkafka/producer.rb
|
112
113
|
- lib/waterdrop/producer.rb
|
113
114
|
- lib/waterdrop/producer/async.rb
|
metadata.gz.sig
CHANGED
Binary file
|