rdkafka 0.15.0 → 0.16.0.beta1
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/.github/workflows/ci.yml +4 -7
- data/.gitignore +2 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +25 -1
- data/README.md +31 -9
- data/docker-compose.yml +1 -1
- data/ext/Rakefile +51 -26
- data/lib/rdkafka/abstract_handle.rb +44 -20
- data/lib/rdkafka/admin/acl_binding_result.rb +38 -24
- data/lib/rdkafka/admin/create_topic_report.rb +1 -1
- data/lib/rdkafka/admin/delete_groups_report.rb +1 -1
- data/lib/rdkafka/admin/delete_topic_report.rb +1 -1
- data/lib/rdkafka/admin.rb +15 -0
- data/lib/rdkafka/bindings.rb +44 -8
- data/lib/rdkafka/callbacks.rb +28 -12
- data/lib/rdkafka/config.rb +69 -15
- data/lib/rdkafka/consumer.rb +39 -17
- data/lib/rdkafka/helpers/oauth.rb +58 -0
- data/lib/rdkafka/native_kafka.rb +32 -19
- data/lib/rdkafka/producer/delivery_handle.rb +12 -1
- data/lib/rdkafka/producer/delivery_report.rb +16 -3
- data/lib/rdkafka/producer.rb +47 -10
- data/lib/rdkafka/version.rb +1 -1
- data/lib/rdkafka.rb +1 -0
- data/rdkafka.gemspec +2 -2
- data/spec/rdkafka/abstract_handle_spec.rb +34 -21
- data/spec/rdkafka/admin/delete_acl_report_spec.rb +1 -0
- data/spec/rdkafka/admin/describe_acl_report_spec.rb +1 -0
- data/spec/rdkafka/admin_spec.rb +53 -0
- data/spec/rdkafka/bindings_spec.rb +97 -0
- data/spec/rdkafka/config_spec.rb +53 -0
- data/spec/rdkafka/consumer_spec.rb +74 -0
- data/spec/rdkafka/native_kafka_spec.rb +8 -1
- data/spec/rdkafka/producer/delivery_report_spec.rb +4 -0
- data/spec/rdkafka/producer_spec.rb +69 -2
- data/spec/spec_helper.rb +16 -1
- data.tar.gz.sig +0 -0
- metadata +6 -4
- metadata.gz.sig +0 -0
@@ -14,6 +14,19 @@ describe Rdkafka::Producer do
|
|
14
14
|
consumer.close
|
15
15
|
end
|
16
16
|
|
17
|
+
describe 'producer without auto-start' do
|
18
|
+
let(:producer) { rdkafka_producer_config.producer(native_kafka_auto_start: false) }
|
19
|
+
|
20
|
+
it 'expect to be able to start it later and close' do
|
21
|
+
producer.start
|
22
|
+
producer.close
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'expect to be able to close it without starting' do
|
26
|
+
producer.close
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
17
30
|
describe '#name' do
|
18
31
|
it { expect(producer.name).to include('rdkafka#producer-') }
|
19
32
|
end
|
@@ -34,6 +47,7 @@ describe Rdkafka::Producer do
|
|
34
47
|
|
35
48
|
producer.delivery_callback = lambda do |report|
|
36
49
|
expect(report).not_to be_nil
|
50
|
+
expect(report.label).to eq "label"
|
37
51
|
expect(report.partition).to eq 1
|
38
52
|
expect(report.offset).to be >= 0
|
39
53
|
expect(report.topic_name).to eq "produce_test_topic"
|
@@ -44,9 +58,12 @@ describe Rdkafka::Producer do
|
|
44
58
|
handle = producer.produce(
|
45
59
|
topic: "produce_test_topic",
|
46
60
|
payload: "payload",
|
47
|
-
key: "key"
|
61
|
+
key: "key",
|
62
|
+
label: "label"
|
48
63
|
)
|
49
64
|
|
65
|
+
expect(handle.label).to eq "label"
|
66
|
+
|
50
67
|
# Wait for it to be delivered
|
51
68
|
handle.wait(max_wait_timeout: 15)
|
52
69
|
|
@@ -175,11 +192,13 @@ describe Rdkafka::Producer do
|
|
175
192
|
handle = producer.produce(
|
176
193
|
topic: "produce_test_topic",
|
177
194
|
payload: "payload",
|
178
|
-
key: "key"
|
195
|
+
key: "key",
|
196
|
+
label: "label"
|
179
197
|
)
|
180
198
|
|
181
199
|
# Should be pending at first
|
182
200
|
expect(handle.pending?).to be true
|
201
|
+
expect(handle.label).to eq "label"
|
183
202
|
|
184
203
|
# Check delivery handle and report
|
185
204
|
report = handle.wait(max_wait_timeout: 5)
|
@@ -187,6 +206,7 @@ describe Rdkafka::Producer do
|
|
187
206
|
expect(report).not_to be_nil
|
188
207
|
expect(report.partition).to eq 1
|
189
208
|
expect(report.offset).to be >= 0
|
209
|
+
expect(report.label).to eq "label"
|
190
210
|
|
191
211
|
# Flush and close producer
|
192
212
|
producer.flush
|
@@ -558,6 +578,23 @@ describe Rdkafka::Producer do
|
|
558
578
|
end
|
559
579
|
end
|
560
580
|
|
581
|
+
context "when not being able to deliver the message" do
|
582
|
+
let(:producer) do
|
583
|
+
rdkafka_producer_config(
|
584
|
+
"bootstrap.servers": "localhost:9093",
|
585
|
+
"message.timeout.ms": 100
|
586
|
+
).producer
|
587
|
+
end
|
588
|
+
|
589
|
+
it "should contain the error in the response when not deliverable" do
|
590
|
+
handler = producer.produce(topic: 'produce_test_topic', payload: nil, label: 'na')
|
591
|
+
# Wait for the async callbacks and delivery registry to update
|
592
|
+
sleep(2)
|
593
|
+
expect(handler.create_result.error).to be_a(Rdkafka::RdkafkaError)
|
594
|
+
expect(handler.create_result.label).to eq('na')
|
595
|
+
end
|
596
|
+
end
|
597
|
+
|
561
598
|
describe '#partition_count' do
|
562
599
|
it { expect(producer.partition_count('consume_test_topic')).to eq(3) }
|
563
600
|
|
@@ -710,4 +747,34 @@ describe Rdkafka::Producer do
|
|
710
747
|
end
|
711
748
|
end
|
712
749
|
end
|
750
|
+
|
751
|
+
describe '#oauthbearer_set_token' do
|
752
|
+
context 'when sasl not configured' do
|
753
|
+
it 'should return RD_KAFKA_RESP_ERR__STATE' do
|
754
|
+
response = producer.oauthbearer_set_token(
|
755
|
+
token: "foo",
|
756
|
+
lifetime_ms: Time.now.to_i*1000 + 900 * 1000,
|
757
|
+
principal_name: "kafka-cluster"
|
758
|
+
)
|
759
|
+
expect(response).to eq(Rdkafka::Bindings::RD_KAFKA_RESP_ERR__STATE)
|
760
|
+
end
|
761
|
+
end
|
762
|
+
|
763
|
+
context 'when sasl configured' do
|
764
|
+
it 'should succeed' do
|
765
|
+
producer_sasl = rdkafka_producer_config(
|
766
|
+
{
|
767
|
+
"security.protocol": "sasl_ssl",
|
768
|
+
"sasl.mechanisms": 'OAUTHBEARER'
|
769
|
+
}
|
770
|
+
).producer
|
771
|
+
response = producer_sasl.oauthbearer_set_token(
|
772
|
+
token: "foo",
|
773
|
+
lifetime_ms: Time.now.to_i*1000 + 900 * 1000,
|
774
|
+
principal_name: "kafka-cluster"
|
775
|
+
)
|
776
|
+
expect(response).to eq(0)
|
777
|
+
end
|
778
|
+
end
|
779
|
+
end
|
713
780
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -139,7 +139,7 @@ RSpec.configure do |config|
|
|
139
139
|
}.each do |topic, partitions|
|
140
140
|
create_topic_handle = admin.create_topic(topic.to_s, partitions, 1)
|
141
141
|
begin
|
142
|
-
create_topic_handle.wait(max_wait_timeout:
|
142
|
+
create_topic_handle.wait(max_wait_timeout: 1.0)
|
143
143
|
rescue Rdkafka::RdkafkaError => ex
|
144
144
|
raise unless ex.message.match?(/topic_already_exists/)
|
145
145
|
end
|
@@ -155,3 +155,18 @@ RSpec.configure do |config|
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
end
|
158
|
+
|
159
|
+
class RdKafkaTestConsumer
|
160
|
+
def self.with
|
161
|
+
consumer = Rdkafka::Bindings.rd_kafka_new(
|
162
|
+
:rd_kafka_consumer,
|
163
|
+
nil,
|
164
|
+
nil,
|
165
|
+
0
|
166
|
+
)
|
167
|
+
yield consumer
|
168
|
+
ensure
|
169
|
+
Rdkafka::Bindings.rd_kafka_consumer_close(consumer)
|
170
|
+
Rdkafka::Bindings.rd_kafka_destroy(consumer)
|
171
|
+
end
|
172
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdkafka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thijs Cadier
|
8
|
+
- Maciej Mensfeld
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain:
|
@@ -35,7 +36,7 @@ cert_chain:
|
|
35
36
|
AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
|
36
37
|
msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
|
37
38
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
39
|
+
date: 2024-04-29 00:00:00.000000000 Z
|
39
40
|
dependencies:
|
40
41
|
- !ruby/object:Gem::Dependency
|
41
42
|
name: ffi
|
@@ -215,6 +216,7 @@ files:
|
|
215
216
|
- lib/rdkafka/consumer/partition.rb
|
216
217
|
- lib/rdkafka/consumer/topic_partition_list.rb
|
217
218
|
- lib/rdkafka/error.rb
|
219
|
+
- lib/rdkafka/helpers/oauth.rb
|
218
220
|
- lib/rdkafka/helpers/time.rb
|
219
221
|
- lib/rdkafka/metadata.rb
|
220
222
|
- lib/rdkafka/native_kafka.rb
|
@@ -277,12 +279,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
279
|
- !ruby/object:Gem::Version
|
278
280
|
version: '0'
|
279
281
|
requirements: []
|
280
|
-
rubygems_version: 3.
|
282
|
+
rubygems_version: 3.5.9
|
281
283
|
signing_key:
|
282
284
|
specification_version: 4
|
283
285
|
summary: The rdkafka gem is a modern Kafka client library for Ruby based on librdkafka.
|
284
286
|
It wraps the production-ready C client using the ffi gem and targets Kafka 1.0+
|
285
|
-
and Ruby 2.
|
287
|
+
and Ruby 2.7+.
|
286
288
|
test_files:
|
287
289
|
- spec/rdkafka/abstract_handle_spec.rb
|
288
290
|
- spec/rdkafka/admin/create_acl_handle_spec.rb
|
metadata.gz.sig
CHANGED
Binary file
|