karafka-rdkafka 0.14.4 → 0.14.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d22e33d93f77f138063f03111b25386c08e1667012b6ab4c8449fef61754ad44
4
- data.tar.gz: b8cc0557cbb945e5d7b7e025198a292a7cf601ce9decef97cb5102fd25af742b
3
+ metadata.gz: 5ed56a133dd27e17055cf63b7e68945d9cb97b42690afa6c7eb230f56273754c
4
+ data.tar.gz: bcb63a1c2c77d599ab403bfdca1df0badd28f1c1cc72eed16169e6d4044fe778
5
5
  SHA512:
6
- metadata.gz: cfc9af0e70030f513c4c34b00f9b94b6b3b9c828add2ac6cd742ebe2eb308a1e1a5489bf4c4280c34a98d2f0118d741608918314fa8f267b7cf98b22b3d8782d
7
- data.tar.gz: 315b552a77691b62e5a30fd5eaec1bf89efd8ec5789f9f0deeadf3997eeca9dc83bb6466ee8365e40e53d2e09707d3d68a57278b3637b170ad027b5080838519
6
+ metadata.gz: '07185f868e86c3aaa917f8be42a14047cfb9dd9901001351f416f14338bf1dcc942b4d4649749832efed5c10cb3c7e9ea3543706fd7e11bb79fc332206569898'
7
+ data.tar.gz: c7bafd507d2b86c9ae61daab5ed32b142ec6d9e7dbd6d4cf26a704d432b257c00e84fb8872daab978c685941ab71e3201d7fe05635fa0fc8526eac016faf48d9
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Rdkafka Changelog
2
2
 
3
+ ## 0.14.5 (2023-12-20)
4
+ - [Enhancement] Provide `label` producer handler and report reference for improved traceability.
5
+
3
6
  ## 0.14.4 (2023-12-19)
4
7
  - [Enhancement] Add ability to store offsets in a transaction (mensfeld)
5
8
 
@@ -288,7 +288,16 @@ module Rdkafka
288
288
 
289
289
  # Call delivery callback on opaque
290
290
  if opaque = Rdkafka::Config.opaques[opaque_ptr.to_i]
291
- opaque.call_delivery_callback(Rdkafka::Producer::DeliveryReport.new(message[:partition], message[:offset], topic_name, message[:err]), delivery_handle)
291
+ opaque.call_delivery_callback(
292
+ Rdkafka::Producer::DeliveryReport.new(
293
+ message[:partition],
294
+ message[:offset],
295
+ topic_name,
296
+ message[:err],
297
+ delivery_handle.label
298
+ ),
299
+ delivery_handle
300
+ )
292
301
  end
293
302
  end
294
303
  end
@@ -11,6 +11,9 @@ module Rdkafka
11
11
  :offset, :int64,
12
12
  :topic_name, :pointer
13
13
 
14
+ # @return [Object, nil] label set during message production or nil by default
15
+ attr_accessor :label
16
+
14
17
  # @return [String] the name of the operation (e.g. "delivery")
15
18
  def operation_name
16
19
  "delivery"
@@ -22,7 +25,9 @@ module Rdkafka
22
25
  DeliveryReport.new(
23
26
  self[:partition],
24
27
  self[:offset],
25
- self[:topic_name].read_string
28
+ self[:topic_name].read_string,
29
+ nil,
30
+ label
26
31
  )
27
32
  else
28
33
  DeliveryReport.new(
@@ -31,7 +36,8 @@ module Rdkafka
31
36
  # For part of errors, we will not get a topic name reference and in cases like this
32
37
  # we should not return it
33
38
  self[:topic_name].null? ? nil : self[:topic_name].read_string,
34
- Rdkafka::RdkafkaError.build(self[:response])
39
+ Rdkafka::RdkafkaError.build(self[:response]),
40
+ label
35
41
  )
36
42
  end
37
43
  end
@@ -21,6 +21,9 @@ module Rdkafka
21
21
  # @return [Integer]
22
22
  attr_reader :error
23
23
 
24
+ # @return [Object, nil] label set during message production or nil by default
25
+ attr_reader :label
26
+
24
27
  # We alias the `#topic_name` under `#topic` to make this consistent with `Consumer::Message`
25
28
  # where the topic name is under `#topic` method. That way we have a consistent name that
26
29
  # is present in both places
@@ -30,11 +33,12 @@ module Rdkafka
30
33
 
31
34
  private
32
35
 
33
- def initialize(partition, offset, topic_name = nil, error = nil)
36
+ def initialize(partition, offset, topic_name = nil, error = nil, label = nil)
34
37
  @partition = partition
35
38
  @offset = offset
36
39
  @topic_name = topic_name
37
40
  @error = error
41
+ @label = label
38
42
  end
39
43
  end
40
44
  end
@@ -226,11 +226,12 @@ module Rdkafka
226
226
  # @param partition_key [String, nil] Optional partition key based on which partition assignment can happen
227
227
  # @param timestamp [Time,Integer,nil] Optional timestamp of this message. Integer timestamp is in milliseconds since Jan 1 1970.
228
228
  # @param headers [Hash<String,String>] Optional message headers
229
+ # @param label [Object, nil] a label that can be assigned when producing a message that will be part of the delivery handle and the delivery report
229
230
  #
230
231
  # @return [DeliveryHandle] Delivery handle that can be used to wait for the result of producing this message
231
232
  #
232
233
  # @raise [RdkafkaError] When adding the message to rdkafka's queue failed
233
- def produce(topic:, payload: nil, key: nil, partition: nil, partition_key: nil, timestamp: nil, headers: nil)
234
+ def produce(topic:, payload: nil, key: nil, partition: nil, partition_key: nil, timestamp: nil, headers: nil, label: nil)
234
235
  closed_producer_check(__method__)
235
236
 
236
237
  # Start by checking and converting the input
@@ -272,6 +273,7 @@ module Rdkafka
272
273
  end
273
274
 
274
275
  delivery_handle = DeliveryHandle.new
276
+ delivery_handle.label = label
275
277
  delivery_handle[:pending] = true
276
278
  delivery_handle[:response] = -1
277
279
  delivery_handle[:partition] = -1
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rdkafka
4
- VERSION = "0.14.4"
4
+ VERSION = "0.14.5"
5
5
  LIBRDKAFKA_VERSION = "2.3.0"
6
6
  LIBRDKAFKA_SOURCE_SHA256 = "2d49c35c77eeb3d42fa61c43757fcbb6a206daa560247154e60642bcdcc14d12"
7
7
  end
@@ -34,6 +34,7 @@ describe Rdkafka::Producer do
34
34
 
35
35
  producer.delivery_callback = lambda do |report|
36
36
  expect(report).not_to be_nil
37
+ expect(report.label).to eq "label"
37
38
  expect(report.partition).to eq 1
38
39
  expect(report.offset).to be >= 0
39
40
  expect(report.topic_name).to eq "produce_test_topic"
@@ -44,9 +45,12 @@ describe Rdkafka::Producer do
44
45
  handle = producer.produce(
45
46
  topic: "produce_test_topic",
46
47
  payload: "payload",
47
- key: "key"
48
+ key: "key",
49
+ label: "label"
48
50
  )
49
51
 
52
+ expect(handle.label).to eq "label"
53
+
50
54
  # Wait for it to be delivered
51
55
  handle.wait(max_wait_timeout: 15)
52
56
 
@@ -175,11 +179,13 @@ describe Rdkafka::Producer do
175
179
  handle = producer.produce(
176
180
  topic: "produce_test_topic",
177
181
  payload: "payload",
178
- key: "key"
182
+ key: "key",
183
+ label: "label"
179
184
  )
180
185
 
181
186
  # Should be pending at first
182
187
  expect(handle.pending?).to be true
188
+ expect(handle.label).to eq "label"
183
189
 
184
190
  # Check delivery handle and report
185
191
  report = handle.wait(max_wait_timeout: 5)
@@ -187,6 +193,7 @@ describe Rdkafka::Producer do
187
193
  expect(report).not_to be_nil
188
194
  expect(report.partition).to eq 1
189
195
  expect(report.offset).to be >= 0
196
+ expect(report.label).to eq "label"
190
197
 
191
198
  # Flush and close producer
192
199
  producer.flush
@@ -567,10 +574,11 @@ describe Rdkafka::Producer do
567
574
  end
568
575
 
569
576
  it "should contain the error in the response when not deliverable" do
570
- handler = producer.produce(topic: 'produce_test_topic', payload: nil)
577
+ handler = producer.produce(topic: 'produce_test_topic', payload: nil, label: 'na')
571
578
  # Wait for the async callbacks and delivery registry to update
572
579
  sleep(2)
573
580
  expect(handler.create_result.error).to be_a(Rdkafka::RdkafkaError)
581
+ expect(handler.create_result.label).to eq('na')
574
582
  end
575
583
  end
576
584
 
data.tar.gz.sig CHANGED
Binary file
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.14.4
4
+ version: 0.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thijs Cadier
@@ -35,7 +35,7 @@ cert_chain:
35
35
  AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
36
36
  msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
37
37
  -----END CERTIFICATE-----
38
- date: 2023-12-19 00:00:00.000000000 Z
38
+ date: 2023-12-20 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ffi
metadata.gz.sig CHANGED
Binary file