waterdrop 2.4.4 → 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 +4 -0
- data/Gemfile.lock +1 -1
- data/lib/waterdrop/patches/rdkafka/metadata.rb +1 -1
- data/lib/waterdrop/patches/rdkafka/producer.rb +51 -6
- data/lib/waterdrop/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: 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,9 @@
|
|
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
|
+
|
3
7
|
## 2.4.4 (2022-12-09)
|
4
8
|
- Add temporary patch on top of `rdkafka-ruby` to mitigate metadata fetch timeout failures.
|
5
9
|
|
data/Gemfile.lock
CHANGED
@@ -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
Binary file
|
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
|
metadata.gz.sig
CHANGED
Binary file
|