rdkafka 0.12.0.beta.1 → 0.12.0.beta.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/rdkafka/bindings.rb +10 -3
- data/lib/rdkafka/config.rb +1 -1
- data/lib/rdkafka/producer.rb +3 -2
- data/lib/rdkafka/version.rb +3 -3
- data/spec/rdkafka/bindings_spec.rb +7 -0
- data/spec/rdkafka/producer/client_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e539d59efa2f340f4e746eb56458a2ec7ccc4b3772339c92168b49afa6eefe3
|
4
|
+
data.tar.gz: 88b22c82f5580adf63657384afde3d395ea72ad7d35a8f98aa4f55ba57ed9fd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bfbed165c2df7b716c93014c5f20df64aa3177e7c5799603a4315e823dfea935f27a58875eb2453b8b87163ab32dcae26e2aef86640e8ebf74fe5b1b13adae2
|
7
|
+
data.tar.gz: 25cbc82bbfa3b92070c4d33dd9105ff6b73892345437077127e63027855b78ecba80ca1e4be133175cb1efa720d1547f1991523e7f71b1a863dbf0d28356720a
|
data/CHANGELOG.md
CHANGED
data/lib/rdkafka/bindings.rb
CHANGED
@@ -246,14 +246,21 @@ module Rdkafka
|
|
246
246
|
attach_function :rd_kafka_conf_set_dr_msg_cb, [:pointer, :delivery_cb], :void
|
247
247
|
|
248
248
|
# Partitioner
|
249
|
-
|
249
|
+
PARTITIONERS = %w(random consistent consistent_random murmur2 murmur2_random fnv1a fnv1a_random).each_with_object({}) do |name, hsh|
|
250
|
+
method_name = "rd_kafka_msg_partitioner_#{name}".to_sym
|
251
|
+
attach_function method_name, [:pointer, :pointer, :size_t, :int32, :pointer, :pointer], :int32
|
252
|
+
hsh[name] = method_name
|
253
|
+
end
|
250
254
|
|
251
|
-
def self.partitioner(str, partition_count)
|
255
|
+
def self.partitioner(str, partition_count, partitioner_name = "consistent_random")
|
252
256
|
# Return RD_KAFKA_PARTITION_UA(unassigned partition) when partition count is nil/zero.
|
253
257
|
return -1 unless partition_count&.nonzero?
|
254
258
|
|
255
259
|
str_ptr = FFI::MemoryPointer.from_string(str)
|
256
|
-
|
260
|
+
method_name = PARTITIONERS.fetch(partitioner_name) do
|
261
|
+
raise Rdkafka::Config::ConfigError.new("Unknown partitioner: #{partitioner_name}")
|
262
|
+
end
|
263
|
+
public_send(method_name, nil, str_ptr, str.size, partition_count, nil, nil)
|
257
264
|
end
|
258
265
|
|
259
266
|
# Create Topics
|
data/lib/rdkafka/config.rb
CHANGED
@@ -179,7 +179,7 @@ module Rdkafka
|
|
179
179
|
# Set callback to receive delivery reports on config
|
180
180
|
Rdkafka::Bindings.rd_kafka_conf_set_dr_msg_cb(config, Rdkafka::Callbacks::DeliveryCallbackFunction)
|
181
181
|
# Return producer with Kafka client
|
182
|
-
Rdkafka::Producer.new(Rdkafka::Producer::Client.new(native_kafka(config, :rd_kafka_producer))).tap do |producer|
|
182
|
+
Rdkafka::Producer.new(Rdkafka::Producer::Client.new(native_kafka(config, :rd_kafka_producer)), self[:partitioner]).tap do |producer|
|
183
183
|
opaque.producer = producer
|
184
184
|
end
|
185
185
|
end
|
data/lib/rdkafka/producer.rb
CHANGED
@@ -10,8 +10,9 @@ module Rdkafka
|
|
10
10
|
attr_reader :delivery_callback
|
11
11
|
|
12
12
|
# @private
|
13
|
-
def initialize(client)
|
13
|
+
def initialize(client, partitioner_name)
|
14
14
|
@client = client
|
15
|
+
@partitioner_name = partitioner_name || "consistent_random"
|
15
16
|
|
16
17
|
# Makes sure, that the producer gets closed before it gets GCed by Ruby
|
17
18
|
ObjectSpace.define_finalizer(self, client.finalizer)
|
@@ -85,7 +86,7 @@ module Rdkafka
|
|
85
86
|
if partition_key
|
86
87
|
partition_count = partition_count(topic)
|
87
88
|
# If the topic is not present, set to -1
|
88
|
-
partition = Rdkafka::Bindings.partitioner(partition_key, partition_count) if partition_count
|
89
|
+
partition = Rdkafka::Bindings.partitioner(partition_key, partition_count, @partitioner_name) if partition_count
|
89
90
|
end
|
90
91
|
|
91
92
|
# If partition is nil, use -1 to let librdafka set the partition randomly or
|
data/lib/rdkafka/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Rdkafka
|
2
|
-
VERSION = "0.12.0.beta.
|
3
|
-
LIBRDKAFKA_VERSION = "1.9.0-
|
4
|
-
LIBRDKAFKA_SOURCE_SHA256 = "
|
2
|
+
VERSION = "0.12.0.beta.4"
|
3
|
+
LIBRDKAFKA_VERSION = "1.9.0-RC10"
|
4
|
+
LIBRDKAFKA_SOURCE_SHA256 = "e8d49dcd6aafc169b1a75ed3553a338c4b9cf7821d365bac3c6e31d9a4aa9296"
|
5
5
|
end
|
@@ -76,6 +76,13 @@ describe Rdkafka::Bindings do
|
|
76
76
|
result_2 = (Zlib.crc32(partition_key) % partition_count)
|
77
77
|
expect(result_1).to eq(result_2)
|
78
78
|
end
|
79
|
+
|
80
|
+
it "should return the partition calculated by the specified partitioner" do
|
81
|
+
result_1 = Rdkafka::Bindings.partitioner(partition_key, partition_count, "murmur2")
|
82
|
+
ptr = FFI::MemoryPointer.from_string(partition_key)
|
83
|
+
result_2 = Rdkafka::Bindings.rd_kafka_msg_partitioner_murmur2(nil, ptr, partition_key.size, partition_count, nil, nil)
|
84
|
+
expect(result_1).to eq(result_2)
|
85
|
+
end
|
79
86
|
end
|
80
87
|
|
81
88
|
describe "stats callback" do
|
@@ -42,13 +42,13 @@ describe Rdkafka::Producer::Client do
|
|
42
42
|
|
43
43
|
it "polls the native with default 250ms timeout" do
|
44
44
|
polling_loop_expects do
|
45
|
-
expect(Rdkafka::Bindings).to receive(:rd_kafka_poll).with(instance_of(FFI::Pointer), 250)
|
45
|
+
expect(Rdkafka::Bindings).to receive(:rd_kafka_poll).with(instance_of(FFI::Pointer), 250).at_least(:once)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
it "check the out queue of native client" do
|
50
50
|
polling_loop_expects do
|
51
|
-
expect(Rdkafka::Bindings).to receive(:rd_kafka_outq_len).with(native)
|
51
|
+
expect(Rdkafka::Bindings).to receive(:rd_kafka_outq_len).with(native).at_least(:once)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdkafka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.0.beta.
|
4
|
+
version: 0.12.0.beta.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thijs Cadier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|