karafka-rdkafka 0.14.1 → 0.14.3

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: 31a04189b142cd826aece2945d0a5415996bc72d4d90b1e843dd7db3378f05b3
4
- data.tar.gz: 2ff92cdb856c24e3997e0e3c04b5c96fd9a807965581cec91beb3902b072ef88
3
+ metadata.gz: 5fee43511074dfab207280d7114f70f8fb5cc7b6055fdb348cd9da302ee037d2
4
+ data.tar.gz: 22656cc0b49a6d3aa7d6fad85c1b3c936b49089802ed07f4f43d8fdd85a16f2d
5
5
  SHA512:
6
- metadata.gz: '09f1db3f1be3ce2f665318ba60356d82ebf00b633470fb0ab249e38110f605d9e4a4f5e296c6bb4a29972ad577d2f71f3e5318c26f699fac71b481e2eb622c6a'
7
- data.tar.gz: 6185cdb77c7d75f69052b5df9d5adf8942c28e0b7f842c617fd7f265549e6fa0fcc3cbaa24aeed0c4ea511a24ede8dcbf3a50e0d81ae1289eed627c143764407
6
+ metadata.gz: cdc7873ca1dda1d2afc6193c8e189850d5d3f865f19307cd997cc76c3fa39a919f2757ed610cf18854dc1ff61b270d1a9c85f880257c1c833435d7af9992a27a
7
+ data.tar.gz: ed37156d9f17e8be5804720b426424260c3e70567cf2e24dc385ed5e8d66763199fb056a2c47e11fec1ff80ddaae8b2926f9420b05d1c9e88dc38735c32b4eb1
checksums.yaml.gz.sig CHANGED
Binary file
@@ -22,7 +22,7 @@ jobs:
22
22
  fail-fast: false
23
23
  matrix:
24
24
  ruby:
25
- - '3.3.0-preview2'
25
+ - '3.3.0-rc1'
26
26
  - '3.2'
27
27
  - '3.1'
28
28
  - '3.1.0'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Rdkafka Changelog
2
2
 
3
+ ## 0.14.3 (2023-12-17)
4
+ - [Enhancement] Replace `rd_kafka_offset_store` with `rd_kafka_offsets_store` (mensfeld)
5
+ - [Fix] Missing ACL `RD_KAFKA_RESOURCE_BROKER` constant reference (mensfeld)
6
+ - [Change] Rename `matching_acl_pattern_type` to `matching_acl_resource_pattern_type` to align the whole API (mensfeld)
7
+
8
+ ## 0.14.2 (2023-12-11)
9
+ - [Enhancement] Alias `topic_name` as `topic` in the delivery report (mensfeld)
10
+ - [Fix] Fix return type on `#rd_kafka_poll` (mensfeld)
11
+ - [Fix] `uint8_t` does not exist on Apple Silicon (mensfeld)
12
+
3
13
  ## 0.14.1 (2023-12-02)
4
14
  - **[Feature]** Add `Admin#metadata` (mensfeld)
5
15
  - **[Feature]** Add `Admin#create_partitions` (mensfeld)
@@ -2,36 +2,50 @@
2
2
 
3
3
  module Rdkafka
4
4
  class Admin
5
-
6
5
  # Extracts attributes of rd_kafka_AclBinding_t
7
6
  #
8
7
  class AclBindingResult
9
- attr_reader :result_error, :error_string, :matching_acl_resource_type, :matching_acl_resource_name, :matching_acl_pattern_type, :matching_acl_principal, :matching_acl_host, :matching_acl_operation, :matching_acl_permission_type
8
+ attr_reader :result_error, :error_string, :matching_acl_resource_type,
9
+ :matching_acl_resource_name, :matching_acl_resource_pattern_type,
10
+ :matching_acl_principal, :matching_acl_host, :matching_acl_operation,
11
+ :matching_acl_permission_type
12
+
13
+ # This attribute was initially released under the name that is now an alias
14
+ # We keep it for backwards compatibility but it was changed for the consistency
15
+ alias matching_acl_pattern_type matching_acl_resource_pattern_type
10
16
 
11
17
  def initialize(matching_acl)
12
- rd_kafka_error_pointer = Rdkafka::Bindings.rd_kafka_AclBinding_error(matching_acl)
13
- @result_error = Rdkafka::Bindings.rd_kafka_error_code(rd_kafka_error_pointer)
14
- error_string = Rdkafka::Bindings.rd_kafka_error_string(rd_kafka_error_pointer)
15
- if error_string != FFI::Pointer::NULL
16
- @error_string = error_string.read_string
17
- end
18
- @matching_acl_resource_type = Rdkafka::Bindings.rd_kafka_AclBinding_restype(matching_acl)
19
- matching_acl_resource_name = Rdkafka::Bindings.rd_kafka_AclBinding_name(matching_acl)
20
- if matching_acl_resource_name != FFI::Pointer::NULL
21
- @matching_acl_resource_name = matching_acl_resource_name.read_string
22
- end
23
- @matching_acl_pattern_type = Rdkafka::Bindings.rd_kafka_AclBinding_resource_pattern_type(matching_acl)
24
- matching_acl_principal = Rdkafka::Bindings.rd_kafka_AclBinding_principal(matching_acl)
25
- if matching_acl_principal != FFI::Pointer::NULL
26
- @matching_acl_principal = matching_acl_principal.read_string
27
- end
28
- matching_acl_host = Rdkafka::Bindings.rd_kafka_AclBinding_host(matching_acl)
29
- if matching_acl_host != FFI::Pointer::NULL
30
- @matching_acl_host = matching_acl_host.read_string
31
- end
32
- @matching_acl_operation = Rdkafka::Bindings.rd_kafka_AclBinding_operation(matching_acl)
33
- @matching_acl_permission_type = Rdkafka::Bindings.rd_kafka_AclBinding_permission_type(matching_acl)
18
+ rd_kafka_error_pointer = Rdkafka::Bindings.rd_kafka_AclBinding_error(matching_acl)
19
+ @result_error = Rdkafka::Bindings.rd_kafka_error_code(rd_kafka_error_pointer)
20
+ error_string = Rdkafka::Bindings.rd_kafka_error_string(rd_kafka_error_pointer)
21
+
22
+ if error_string != FFI::Pointer::NULL
23
+ @error_string = error_string.read_string
34
24
  end
25
+
26
+ @matching_acl_resource_type = Rdkafka::Bindings.rd_kafka_AclBinding_restype(matching_acl)
27
+ matching_acl_resource_name = Rdkafka::Bindings.rd_kafka_AclBinding_name(matching_acl)
28
+
29
+ if matching_acl_resource_name != FFI::Pointer::NULL
30
+ @matching_acl_resource_name = matching_acl_resource_name.read_string
31
+ end
32
+
33
+ @matching_acl_resource_pattern_type = Rdkafka::Bindings.rd_kafka_AclBinding_resource_pattern_type(matching_acl)
34
+ matching_acl_principal = Rdkafka::Bindings.rd_kafka_AclBinding_principal(matching_acl)
35
+
36
+ if matching_acl_principal != FFI::Pointer::NULL
37
+ @matching_acl_principal = matching_acl_principal.read_string
38
+ end
39
+
40
+ matching_acl_host = Rdkafka::Bindings.rd_kafka_AclBinding_host(matching_acl)
41
+
42
+ if matching_acl_host != FFI::Pointer::NULL
43
+ @matching_acl_host = matching_acl_host.read_string
44
+ end
45
+
46
+ @matching_acl_operation = Rdkafka::Bindings.rd_kafka_AclBinding_operation(matching_acl)
47
+ @matching_acl_permission_type = Rdkafka::Bindings.rd_kafka_AclBinding_permission_type(matching_acl)
35
48
  end
49
+ end
36
50
  end
37
51
  end
@@ -41,7 +41,7 @@ module Rdkafka
41
41
  # Polling
42
42
 
43
43
  attach_function :rd_kafka_flush, [:pointer, :int], :int, blocking: true
44
- attach_function :rd_kafka_poll, [:pointer, :int], :void, blocking: true
44
+ attach_function :rd_kafka_poll, [:pointer, :int], :int, blocking: true
45
45
  attach_function :rd_kafka_outq_len, [:pointer], :int, blocking: true
46
46
 
47
47
  # Metadata
@@ -199,7 +199,7 @@ module Rdkafka
199
199
  attach_function :rd_kafka_poll_set_consumer, [:pointer], :void, blocking: true
200
200
  attach_function :rd_kafka_consumer_poll, [:pointer, :int], :pointer, blocking: true
201
201
  attach_function :rd_kafka_consumer_close, [:pointer], :void, blocking: true
202
- attach_function :rd_kafka_offset_store, [:pointer, :int32, :int64], :int, blocking: true
202
+ attach_function :rd_kafka_offsets_store, [:pointer, :pointer], :int, blocking: true
203
203
  attach_function :rd_kafka_pause_partitions, [:pointer, :pointer], :int, blocking: true
204
204
  attach_function :rd_kafka_resume_partitions, [:pointer, :pointer], :int, blocking: true
205
205
  attach_function :rd_kafka_seek, [:pointer, :int32, :int64, :int], :int, blocking: true
@@ -412,6 +412,7 @@ module Rdkafka
412
412
  RD_KAFKA_RESOURCE_ANY = 1
413
413
  RD_KAFKA_RESOURCE_TOPIC = 2
414
414
  RD_KAFKA_RESOURCE_GROUP = 3
415
+ RD_KAFKA_RESOURCE_BROKER = 4
415
416
 
416
417
  # rd_kafka_ResourcePatternType_t - https://github.com/confluentinc/librdkafka/blob/292d2a66b9921b783f08147807992e603c7af059/src/rdkafka.h#L7320
417
418
 
@@ -454,9 +455,9 @@ module Rdkafka
454
455
  class NativeError < FFI::Struct # rd_kafka_error_t
455
456
  layout :code, :int32,
456
457
  :errstr, :pointer,
457
- :fatal, :uint8_t,
458
- :retriable, :uint8_t,
459
- :txn_requires_abort, :uint8_t
458
+ :fatal, :u_int8_t,
459
+ :retriable, :u_int8_t,
460
+ :txn_requires_abort, :u_int8_t
460
461
  end
461
462
 
462
463
  attach_function :rd_kafka_group_result_error, [:pointer], NativeError.by_ref # rd_kafka_group_result_t* => rd_kafka_error_t*
@@ -388,28 +388,26 @@ module Rdkafka
388
388
  def store_offset(message)
389
389
  closed_consumer_check(__method__)
390
390
 
391
- # rd_kafka_offset_store is one of the few calls that does not support
392
- # a string as the topic, so create a native topic for it.
393
- native_topic = @native_kafka.with_inner do |inner|
394
- Rdkafka::Bindings.rd_kafka_topic_new(
391
+ list = TopicPartitionList.new
392
+ list.add_topic_and_partitions_with_offsets(
393
+ message.topic,
394
+ message.partition => message.offset + 1
395
+ )
396
+
397
+ tpl = list.to_native_tpl
398
+
399
+ response = @native_kafka.with_inner do |inner|
400
+ Rdkafka::Bindings.rd_kafka_offsets_store(
395
401
  inner,
396
- message.topic,
397
- nil
402
+ tpl
398
403
  )
399
404
  end
400
- response = Rdkafka::Bindings.rd_kafka_offset_store(
401
- native_topic,
402
- message.partition,
403
- message.offset
404
- )
405
405
 
406
406
  Rdkafka::RdkafkaError.validate!(response)
407
407
 
408
408
  nil
409
409
  ensure
410
- if native_topic && !native_topic.null?
411
- Rdkafka::Bindings.rd_kafka_topic_destroy(native_topic)
412
- end
410
+ Rdkafka::Bindings.rd_kafka_topic_partition_list_destroy(tpl) if tpl
413
411
  end
414
412
 
415
413
  # Seek to a particular message. The next poll on the topic/partition will return the
@@ -21,6 +21,13 @@ module Rdkafka
21
21
  # @return [Integer]
22
22
  attr_reader :error
23
23
 
24
+ # We alias the `#topic_name` under `#topic` to make this consistent with `Consumer::Message`
25
+ # where the topic name is under `#topic` method. That way we have a consistent name that
26
+ # is present in both places
27
+ #
28
+ # We do not remove the original `#topic_name` because of backwards compatibility
29
+ alias topic topic_name
30
+
24
31
  private
25
32
 
26
33
  def initialize(partition, offset, topic_name = nil, error = nil)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rdkafka
4
- VERSION = "0.14.1"
4
+ VERSION = "0.14.3"
5
5
  LIBRDKAFKA_VERSION = "2.3.0"
6
6
  LIBRDKAFKA_SOURCE_SHA256 = "2d49c35c77eeb3d42fa61c43757fcbb6a206daa560247154e60642bcdcc14d12"
7
7
  end
@@ -50,6 +50,7 @@ describe Rdkafka::Admin::DeleteAclReport do
50
50
  end
51
51
 
52
52
  it "should get deleted acl resource pattern type as Rdkafka::Bindings::RD_KAFKA_RESOURCE_PATTERN_LITERAL" do
53
+ expect(subject.deleted_acls[0].matching_acl_resource_pattern_type).to eq(Rdkafka::Bindings::RD_KAFKA_RESOURCE_PATTERN_LITERAL)
53
54
  expect(subject.deleted_acls[0].matching_acl_pattern_type).to eq(Rdkafka::Bindings::RD_KAFKA_RESOURCE_PATTERN_LITERAL)
54
55
  end
55
56
 
@@ -51,6 +51,7 @@ describe Rdkafka::Admin::DescribeAclReport do
51
51
  end
52
52
 
53
53
  it "should get matching acl resource pattern type as Rdkafka::Bindings::RD_KAFKA_RESOURCE_PATTERN_LITERAL" do
54
+ expect(subject.acls[0].matching_acl_resource_pattern_type).to eq(Rdkafka::Bindings::RD_KAFKA_RESOURCE_PATTERN_LITERAL)
54
55
  expect(subject.acls[0].matching_acl_pattern_type).to eq(Rdkafka::Bindings::RD_KAFKA_RESOURCE_PATTERN_LITERAL)
55
56
  end
56
57
 
@@ -480,6 +480,8 @@ describe Rdkafka::Consumer do
480
480
  end
481
481
 
482
482
  describe "#store_offset" do
483
+ let(:consumer) { rdkafka_consumer_config('enable.auto.offset.store': false).consumer }
484
+
483
485
  before do
484
486
  config = {}
485
487
  config[:'enable.auto.offset.store'] = false
@@ -542,6 +544,14 @@ describe Rdkafka::Consumer do
542
544
  }.to raise_error(Rdkafka::RdkafkaError)
543
545
  end
544
546
  end
547
+
548
+ context "when trying to use with enable.auto.offset.store set to true" do
549
+ let(:consumer) { rdkafka_consumer_config('enable.auto.offset.store': true).consumer }
550
+
551
+ it "expect to raise invalid configuration error" do
552
+ expect { consumer.store_offset(message) }.to raise_error(Rdkafka::RdkafkaError, /invalid_arg/)
553
+ end
554
+ end
545
555
  end
546
556
  end
547
557
  end
@@ -15,6 +15,10 @@ describe Rdkafka::Producer::DeliveryReport do
15
15
  expect(subject.topic_name).to eq "topic"
16
16
  end
17
17
 
18
+ it "should get the same topic name under topic alias" do
19
+ expect(subject.topic).to eq "topic"
20
+ end
21
+
18
22
  it "should get the error" do
19
23
  expect(subject.error).to eq -1
20
24
  end
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.1
4
+ version: 0.14.3
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-02 00:00:00.000000000 Z
38
+ date: 2023-12-17 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ffi
metadata.gz.sig CHANGED
Binary file