karafka-rdkafka 0.19.4 → 0.19.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8494d0f57fe5d7df88cdddc734857402b54b5cb5c4f94a5a13f05699ef55ac5
4
- data.tar.gz: b0ddb220b0df3ed9d718650218bfaf6f411c03ae5ff3d106d834082f340e2a64
3
+ metadata.gz: e84a931a800cf4fb0e62f0d15de7f53e5c5845e8edfcd240f1939ec445050bdb
4
+ data.tar.gz: f12b221a26faa281f4c9c90b2a55ac8ebc623cf1aa882b0ce8e7ae274aa6a122
5
5
  SHA512:
6
- metadata.gz: 00f5f97ec7ccd5d94f9bdbe8e8477c3a3de3198c670202ed77463b8cff9897ee71fdbfd0ca0ae767a7ea79e99e7b585f8456bb9756212df355e210dd0a1df7ac
7
- data.tar.gz: 59a9f5b31039f5bae70db155434fdb8529c8de89ddd8d1be9e8365670fbf9e62c38ca565c00d5d6f8d161be28705693d012bf9bb982e048843a7634cdbe57f25
6
+ metadata.gz: 225e690444b46ea2469f0a92beb7e27cd105c49b1649c022163996fb994ed67c9adac95573bfa96f23134732a3e4d41f5dbffc970bdffd699de664b4b1b89e73
7
+ data.tar.gz: 1fcb61fd0d7ca98537b59d15235fd84ab202e020828d36cab07b9ecf837eb845fafa7a6624eb760902c5b50050134a30361f16429f2442f43491f76c57bb4340
@@ -51,7 +51,7 @@ jobs:
51
51
  docker compose up -d || (sleep 5 && docker compose up -d)
52
52
 
53
53
  - name: Set up Ruby
54
- uses: ruby/setup-ruby@84684c07c1965536eb4802c8daf1a77968df0cb1 # v1.239.0
54
+ uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
55
55
  with:
56
56
  ruby-version: ${{matrix.ruby}}
57
57
  bundler-cache: true
@@ -86,7 +86,7 @@ jobs:
86
86
  - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
87
87
 
88
88
  - name: Set up Ruby
89
- uses: ruby/setup-ruby@84684c07c1965536eb4802c8daf1a77968df0cb1 # v1.239.0
89
+ uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
90
90
  with:
91
91
  ruby-version: ${{matrix.ruby}}
92
92
  bundler-cache: false
@@ -24,7 +24,7 @@ jobs:
24
24
  fetch-depth: 0
25
25
 
26
26
  - name: Set up Ruby
27
- uses: ruby/setup-ruby@84684c07c1965536eb4802c8daf1a77968df0cb1 # v1.239.0
27
+ uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
28
28
  with:
29
29
  bundler-cache: false
30
30
 
@@ -34,5 +34,4 @@ jobs:
34
34
  bundle install --jobs 4 --retry 3
35
35
  cd ext && bundle exec rake
36
36
 
37
- # Release
38
- - uses: rubygems/release-gem@9e85cb11501bebc2ae661c1500176316d3987059 # v1
37
+ - uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Rdkafka Changelog
2
2
 
3
+ ## 0.19.5 (2025-05-30)
4
+ - [Enhancement] Allow for producing to non-existing topics with `key` and `partition_key` present.
5
+
3
6
  ## 0.19.4 (2025-05-23)
4
7
  - [Change] Move to trusted-publishers and remove signing since no longer needed.
5
8
 
data/Rakefile CHANGED
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Rakefile
4
-
5
3
  require 'bundler/gem_tasks'
6
4
  require "./lib/rdkafka"
7
5
 
@@ -301,6 +301,13 @@ module Rdkafka
301
301
 
302
302
  topic_metadata ? topic_metadata[:partition_count] : -1
303
303
  end
304
+ rescue Rdkafka::RdkafkaError => e
305
+ # If the topic does not exist, it will be created or if not allowed another error will be
306
+ # raised. We here return -1 so this can happen without early error happening on metadata
307
+ # discovery.
308
+ return -1 if e.code == :unknown_topic_or_part
309
+
310
+ raise(e)
304
311
  end
305
312
 
306
313
  # Produces a message to a Kafka topic. The message is added to rdkafka's queue, call {DeliveryHandle#wait wait} on the returned delivery handle to make sure it is delivered.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rdkafka
4
- VERSION = "0.19.4"
4
+ VERSION = "0.19.5"
5
5
  LIBRDKAFKA_VERSION = "2.8.0"
6
6
  LIBRDKAFKA_SOURCE_SHA256 = "5bd1c46f63265f31c6bfcedcde78703f77d28238eadf23821c2b43fc30be3e25"
7
7
  end
@@ -364,6 +364,48 @@ describe Rdkafka::Producer do
364
364
  expect(message.key).to eq "key utf8"
365
365
  end
366
366
 
367
+ it "should produce a message to a non-existing topic with key and partition key" do
368
+ new_topic = "it-#{SecureRandom.uuid}"
369
+
370
+ handle = producer.produce(
371
+ # Needs to be a new topic each time
372
+ topic: new_topic,
373
+ payload: "payload",
374
+ key: "key",
375
+ partition_key: "partition_key",
376
+ label: "label"
377
+ )
378
+
379
+ # Should be pending at first
380
+ expect(handle.pending?).to be true
381
+ expect(handle.label).to eq "label"
382
+
383
+ # Check delivery handle and report
384
+ report = handle.wait(max_wait_timeout: 5)
385
+ expect(handle.pending?).to be false
386
+ expect(report).not_to be_nil
387
+ expect(report.partition).to eq 0
388
+ expect(report.offset).to be >= 0
389
+ expect(report.label).to eq "label"
390
+
391
+ # Flush and close producer
392
+ producer.flush
393
+ producer.close
394
+
395
+ # Consume message and verify its content
396
+ message = wait_for_message(
397
+ topic: new_topic,
398
+ delivery_report: report,
399
+ consumer: consumer
400
+ )
401
+ expect(message.partition).to eq 0
402
+ expect(message.payload).to eq "payload"
403
+ expect(message.key).to eq "key"
404
+ # Since api.version.request is on by default we will get
405
+ # the message creation timestamp if it's not set.
406
+ expect(message.timestamp).to be_within(10).of(Time.now)
407
+ end
408
+
367
409
  context "timestamp" do
368
410
  it "should raise a type error if not nil, integer or time" do
369
411
  expect {
@@ -637,6 +679,25 @@ describe Rdkafka::Producer do
637
679
  end
638
680
  end
639
681
 
682
+ context "when topic does not exist and allow.auto.create.topics is false" do
683
+ let(:producer) do
684
+ rdkafka_producer_config(
685
+ "bootstrap.servers": "localhost:9092",
686
+ "message.timeout.ms": 100,
687
+ "allow.auto.create.topics": false
688
+ ).producer
689
+ end
690
+
691
+ it "should contain the error in the response when not deliverable" do
692
+ handler = producer.produce(topic: "it-#{SecureRandom.uuid}", payload: nil, label: 'na')
693
+ # Wait for the async callbacks and delivery registry to update
694
+ sleep(2)
695
+ expect(handler.create_result.error).to be_a(Rdkafka::RdkafkaError)
696
+ expect(handler.create_result.error.code).to eq(:msg_timed_out)
697
+ expect(handler.create_result.label).to eq('na')
698
+ end
699
+ end
700
+
640
701
  describe '#partition_count' do
641
702
  it { expect(producer.partition_count('example_topic')).to eq(1) }
642
703
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka-rdkafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.4
4
+ version: 0.19.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thijs Cadier