rdkafka 0.15.1 → 0.16.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/ci.yml +2 -5
  4. data/.gitignore +2 -0
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +16 -1
  7. data/README.md +19 -9
  8. data/docker-compose.yml +1 -1
  9. data/ext/Rakefile +8 -0
  10. data/lib/rdkafka/abstract_handle.rb +44 -20
  11. data/lib/rdkafka/admin/config_binding_result.rb +30 -0
  12. data/lib/rdkafka/admin/config_resource_binding_result.rb +18 -0
  13. data/lib/rdkafka/admin/create_topic_report.rb +1 -1
  14. data/lib/rdkafka/admin/delete_groups_report.rb +1 -1
  15. data/lib/rdkafka/admin/delete_topic_report.rb +1 -1
  16. data/lib/rdkafka/admin/describe_acl_report.rb +1 -0
  17. data/lib/rdkafka/admin/describe_configs_handle.rb +33 -0
  18. data/lib/rdkafka/admin/describe_configs_report.rb +54 -0
  19. data/lib/rdkafka/admin/incremental_alter_configs_handle.rb +33 -0
  20. data/lib/rdkafka/admin/incremental_alter_configs_report.rb +54 -0
  21. data/lib/rdkafka/admin.rb +219 -0
  22. data/lib/rdkafka/bindings.rb +86 -3
  23. data/lib/rdkafka/callbacks.rb +103 -19
  24. data/lib/rdkafka/config.rb +69 -15
  25. data/lib/rdkafka/consumer.rb +7 -0
  26. data/lib/rdkafka/helpers/oauth.rb +58 -0
  27. data/lib/rdkafka/native_kafka.rb +32 -19
  28. data/lib/rdkafka/producer.rb +101 -4
  29. data/lib/rdkafka/version.rb +1 -1
  30. data/lib/rdkafka.rb +7 -0
  31. data/rdkafka.gemspec +1 -1
  32. data/spec/rdkafka/abstract_handle_spec.rb +34 -21
  33. data/spec/rdkafka/admin_spec.rb +336 -3
  34. data/spec/rdkafka/bindings_spec.rb +97 -0
  35. data/spec/rdkafka/config_spec.rb +53 -0
  36. data/spec/rdkafka/consumer_spec.rb +54 -0
  37. data/spec/rdkafka/native_kafka_spec.rb +8 -1
  38. data/spec/rdkafka/producer_spec.rb +85 -0
  39. data/spec/spec_helper.rb +16 -1
  40. data.tar.gz.sig +0 -0
  41. metadata +11 -4
  42. metadata.gz.sig +0 -0
@@ -14,10 +14,65 @@ 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
20
33
 
34
+ describe '#produce with topic config alterations' do
35
+ context 'when config is not valid' do
36
+ it 'expect to raise error' do
37
+ expect do
38
+ producer.produce(topic: 'test', payload: '', topic_config: { 'invalid': 'invalid' })
39
+ end.to raise_error(Rdkafka::Config::ConfigError)
40
+ end
41
+ end
42
+
43
+ context 'when config is valid' do
44
+ it 'expect to raise error' do
45
+ expect do
46
+ producer.produce(topic: 'test', payload: '', topic_config: { 'acks': 1 }).wait
47
+ end.not_to raise_error
48
+ end
49
+
50
+ context 'when alteration should change behavior' do
51
+ # This is set incorrectly for a reason
52
+ # If alteration would not work, this will hang the spec suite
53
+ let(:producer) do
54
+ rdkafka_producer_config(
55
+ 'message.timeout.ms': 1_000_000,
56
+ :"bootstrap.servers" => "localhost:9094",
57
+ ).producer
58
+ end
59
+
60
+ it 'expect to give up on delivery fast based on alteration config' do
61
+ expect do
62
+ producer.produce(
63
+ topic: 'produce_config_test',
64
+ payload: 'test',
65
+ topic_config: {
66
+ 'compression.type': 'gzip',
67
+ 'message.timeout.ms': 1
68
+ }
69
+ ).wait
70
+ end.to raise_error(Rdkafka::RdkafkaError, /msg_timed_out/)
71
+ end
72
+ end
73
+ end
74
+ end
75
+
21
76
  context "delivery callback" do
22
77
  context "with a proc/lambda" do
23
78
  it "should set the callback" do
@@ -734,4 +789,34 @@ describe Rdkafka::Producer do
734
789
  end
735
790
  end
736
791
  end
792
+
793
+ describe '#oauthbearer_set_token' do
794
+ context 'when sasl not configured' do
795
+ it 'should return RD_KAFKA_RESP_ERR__STATE' do
796
+ response = producer.oauthbearer_set_token(
797
+ token: "foo",
798
+ lifetime_ms: Time.now.to_i*1000 + 900 * 1000,
799
+ principal_name: "kafka-cluster"
800
+ )
801
+ expect(response).to eq(Rdkafka::Bindings::RD_KAFKA_RESP_ERR__STATE)
802
+ end
803
+ end
804
+
805
+ context 'when sasl configured' do
806
+ it 'should succeed' do
807
+ producer_sasl = rdkafka_producer_config(
808
+ {
809
+ "security.protocol": "sasl_ssl",
810
+ "sasl.mechanisms": 'OAUTHBEARER'
811
+ }
812
+ ).producer
813
+ response = producer_sasl.oauthbearer_set_token(
814
+ token: "foo",
815
+ lifetime_ms: Time.now.to_i*1000 + 900 * 1000,
816
+ principal_name: "kafka-cluster"
817
+ )
818
+ expect(response).to eq(0)
819
+ end
820
+ end
821
+ end
737
822
  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: 15)
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdkafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.1
4
+ version: 0.16.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thijs Cadier
@@ -36,7 +36,7 @@ cert_chain:
36
36
  AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
37
37
  msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
38
38
  -----END CERTIFICATE-----
39
- date: 2024-01-30 00:00:00.000000000 Z
39
+ date: 2024-05-27 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ffi
@@ -193,6 +193,8 @@ files:
193
193
  - lib/rdkafka/abstract_handle.rb
194
194
  - lib/rdkafka/admin.rb
195
195
  - lib/rdkafka/admin/acl_binding_result.rb
196
+ - lib/rdkafka/admin/config_binding_result.rb
197
+ - lib/rdkafka/admin/config_resource_binding_result.rb
196
198
  - lib/rdkafka/admin/create_acl_handle.rb
197
199
  - lib/rdkafka/admin/create_acl_report.rb
198
200
  - lib/rdkafka/admin/create_partitions_handle.rb
@@ -207,6 +209,10 @@ files:
207
209
  - lib/rdkafka/admin/delete_topic_report.rb
208
210
  - lib/rdkafka/admin/describe_acl_handle.rb
209
211
  - lib/rdkafka/admin/describe_acl_report.rb
212
+ - lib/rdkafka/admin/describe_configs_handle.rb
213
+ - lib/rdkafka/admin/describe_configs_report.rb
214
+ - lib/rdkafka/admin/incremental_alter_configs_handle.rb
215
+ - lib/rdkafka/admin/incremental_alter_configs_report.rb
210
216
  - lib/rdkafka/bindings.rb
211
217
  - lib/rdkafka/callbacks.rb
212
218
  - lib/rdkafka/config.rb
@@ -216,6 +222,7 @@ files:
216
222
  - lib/rdkafka/consumer/partition.rb
217
223
  - lib/rdkafka/consumer/topic_partition_list.rb
218
224
  - lib/rdkafka/error.rb
225
+ - lib/rdkafka/helpers/oauth.rb
219
226
  - lib/rdkafka/helpers/time.rb
220
227
  - lib/rdkafka/metadata.rb
221
228
  - lib/rdkafka/native_kafka.rb
@@ -271,14 +278,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
271
278
  requirements:
272
279
  - - ">="
273
280
  - !ruby/object:Gem::Version
274
- version: '2.7'
281
+ version: '3.0'
275
282
  required_rubygems_version: !ruby/object:Gem::Requirement
276
283
  requirements:
277
284
  - - ">="
278
285
  - !ruby/object:Gem::Version
279
286
  version: '0'
280
287
  requirements: []
281
- rubygems_version: 3.5.3
288
+ rubygems_version: 3.5.9
282
289
  signing_key:
283
290
  specification_version: 4
284
291
  summary: The rdkafka gem is a modern Kafka client library for Ruby based on librdkafka.
metadata.gz.sig CHANGED
Binary file