karafka-rdkafka 0.30.2-aarch64-linux-gnu → 0.32.0-aarch64-linux-gnu
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 +4 -4
- data/CHANGELOG.md +100 -36
- data/README.md +3 -1
- data/docker-compose-ssl.yml +1 -0
- data/docker-compose.yml +1 -0
- data/ext/librdkafka.so +0 -0
- data/karafka-rdkafka.gemspec +5 -4
- data/lib/rdkafka/admin/acl_binding_result.rb +4 -16
- data/lib/rdkafka/admin/alter_consumer_group_offsets_report.rb +2 -2
- data/lib/rdkafka/admin/create_acl_report.rb +1 -3
- data/lib/rdkafka/admin/create_topic_report.rb +2 -6
- data/lib/rdkafka/admin/delete_consumer_group_offsets_report.rb +2 -2
- data/lib/rdkafka/admin/delete_groups_report.rb +2 -6
- data/lib/rdkafka/admin/delete_topic_report.rb +2 -6
- data/lib/rdkafka/admin/describe_cluster_handle.rb +31 -0
- data/lib/rdkafka/admin/describe_cluster_report.rb +51 -0
- data/lib/rdkafka/admin/describe_consumer_groups_handle.rb +31 -0
- data/lib/rdkafka/admin/describe_consumer_groups_report.rb +151 -0
- data/lib/rdkafka/admin/describe_result_parsing.rb +47 -0
- data/lib/rdkafka/admin/describe_topics_handle.rb +31 -0
- data/lib/rdkafka/admin/describe_topics_report.rb +118 -0
- data/lib/rdkafka/admin/list_consumer_group_offsets_handle.rb +31 -0
- data/lib/rdkafka/admin/list_consumer_group_offsets_report.rb +52 -0
- data/lib/rdkafka/admin.rb +424 -9
- data/lib/rdkafka/bindings/admin/acls.rb +85 -0
- data/lib/rdkafka/bindings/admin/configs.rb +37 -0
- data/lib/rdkafka/bindings/admin/list_offsets.rb +26 -0
- data/lib/rdkafka/bindings/admin.rb +211 -0
- data/lib/rdkafka/bindings/callbacks.rb +155 -0
- data/lib/rdkafka/bindings/configuration.rb +50 -0
- data/lib/rdkafka/bindings/consumer.rb +125 -0
- data/lib/rdkafka/bindings/errors.rb +17 -0
- data/lib/rdkafka/bindings/handle.rb +16 -0
- data/lib/rdkafka/bindings/messages.rb +28 -0
- data/lib/rdkafka/bindings/metadata.rb +17 -0
- data/lib/rdkafka/bindings/polling.rb +17 -0
- data/lib/rdkafka/bindings/producer.rb +82 -0
- data/lib/rdkafka/bindings/share_consumer.rb +67 -0
- data/lib/rdkafka/bindings/structs.rb +62 -0
- data/lib/rdkafka/bindings.rb +16 -775
- data/lib/rdkafka/callbacks/describe_cluster_handler.rb +36 -0
- data/lib/rdkafka/callbacks/describe_consumer_groups_handler.rb +36 -0
- data/lib/rdkafka/callbacks/describe_topics_handler.rb +36 -0
- data/lib/rdkafka/callbacks/list_consumer_group_offsets_handler.rb +62 -0
- data/lib/rdkafka/callbacks.rb +15 -7
- data/lib/rdkafka/clients.rb +13 -46
- data/lib/rdkafka/config.rb +70 -0
- data/lib/rdkafka/consumer/allocator.rb +0 -2
- data/lib/rdkafka/consumer/message.rb +6 -9
- data/lib/rdkafka/consumer/topic_partition_list.rb +7 -7
- data/lib/rdkafka/consumer.rb +76 -36
- data/lib/rdkafka/defaults.rb +6 -4
- data/lib/rdkafka/native_kafka.rb +45 -31
- data/lib/rdkafka/producer/delivery_handle.rb +18 -16
- data/lib/rdkafka/producer/delivery_report.rb +51 -1
- data/lib/rdkafka/producer/partitions_count_cache.rb +109 -26
- data/lib/rdkafka/producer.rb +141 -71
- data/lib/rdkafka/share_consumer.rb +70 -34
- data/lib/rdkafka/version.rb +3 -3
- data/lib/rdkafka.rb +14 -1
- data/package-lock.json +9 -9
- data/renovate.json +7 -0
- metadata +31 -31
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Bindings
|
|
5
|
+
# Polling
|
|
6
|
+
|
|
7
|
+
attach_function :rd_kafka_flush, [:pointer, :int], :int, blocking: true
|
|
8
|
+
attach_function :rd_kafka_poll, [:pointer, :int], :int, blocking: true
|
|
9
|
+
attach_function :rd_kafka_outq_len, [:pointer], :int, blocking: true
|
|
10
|
+
|
|
11
|
+
# Non-blocking poll variants (do not release GVL)
|
|
12
|
+
# These are more efficient for poll(0) calls in fiber schedulers where GVL
|
|
13
|
+
# release/reacquire overhead is wasteful since we don't expect to wait.
|
|
14
|
+
# Uses the same underlying C function but with blocking: false to skip GVL release.
|
|
15
|
+
attach_function :rd_kafka_poll_nb, :rd_kafka_poll, [:pointer, :int], :int, blocking: false
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Bindings
|
|
5
|
+
# Producer
|
|
6
|
+
RD_KAFKA_VTYPE_END = 0
|
|
7
|
+
RD_KAFKA_VTYPE_TOPIC = 1
|
|
8
|
+
RD_KAFKA_VTYPE_RKT = 2
|
|
9
|
+
RD_KAFKA_VTYPE_PARTITION = 3
|
|
10
|
+
RD_KAFKA_VTYPE_VALUE = 4
|
|
11
|
+
RD_KAFKA_VTYPE_KEY = 5
|
|
12
|
+
RD_KAFKA_VTYPE_OPAQUE = 6
|
|
13
|
+
RD_KAFKA_VTYPE_MSGFLAGS = 7
|
|
14
|
+
RD_KAFKA_VTYPE_TIMESTAMP = 8
|
|
15
|
+
RD_KAFKA_VTYPE_HEADER = 9
|
|
16
|
+
RD_KAFKA_VTYPE_HEADERS = 10
|
|
17
|
+
RD_KAFKA_PURGE_F_QUEUE = 1
|
|
18
|
+
RD_KAFKA_PURGE_F_INFLIGHT = 2
|
|
19
|
+
|
|
20
|
+
RD_KAFKA_MSG_F_COPY = 0x2
|
|
21
|
+
|
|
22
|
+
attach_function :rd_kafka_producev, [:pointer, :varargs], :int, blocking: true
|
|
23
|
+
attach_function :rd_kafka_purge, [:pointer, :int], :int, blocking: true
|
|
24
|
+
callback :delivery_cb, [:pointer, :pointer, :pointer], :void
|
|
25
|
+
attach_function :rd_kafka_conf_set_dr_msg_cb, [:pointer, :delivery_cb], :void
|
|
26
|
+
attach_function :rd_kafka_init_transactions, [:pointer, :int], :pointer, blocking: true
|
|
27
|
+
attach_function :rd_kafka_send_offsets_to_transaction, [:pointer, :pointer, :pointer, :int], :pointer, blocking: true
|
|
28
|
+
attach_function :rd_kafka_begin_transaction, [:pointer], :pointer, blocking: true
|
|
29
|
+
attach_function :rd_kafka_abort_transaction, [:pointer, :int], :pointer, blocking: true
|
|
30
|
+
attach_function :rd_kafka_commit_transaction, [:pointer, :int], :pointer, blocking: true
|
|
31
|
+
|
|
32
|
+
# Hash mapping partitioner names to their FFI function symbols
|
|
33
|
+
# @return [Hash{String => Symbol}]
|
|
34
|
+
PARTITIONERS = %w[random consistent consistent_random murmur2 murmur2_random fnv1a fnv1a_random].each_with_object({}) do |name, hsh|
|
|
35
|
+
method_name = :"rd_kafka_msg_partitioner_#{name}"
|
|
36
|
+
attach_function method_name, [:pointer, :pointer, :size_t, :int32, :pointer, :pointer], :int32
|
|
37
|
+
hsh[name] = method_name
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Calculates the partition for a message based on the partitioner
|
|
41
|
+
#
|
|
42
|
+
# @param topic_ptr [FFI::Pointer] pointer to the topic handle
|
|
43
|
+
# @param str [String] the partition key string
|
|
44
|
+
# @param partition_count [Integer, nil] number of partitions
|
|
45
|
+
# @param partitioner [String] name of the partitioner to use
|
|
46
|
+
# @return [Integer] partition number or RD_KAFKA_PARTITION_UA if unassigned
|
|
47
|
+
# @raise [Rdkafka::Config::ConfigError] when an unknown partitioner is specified
|
|
48
|
+
def self.partitioner(topic_ptr, str, partition_count, partitioner = "consistent_random")
|
|
49
|
+
# Return RD_KAFKA_PARTITION_UA(unassigned partition) when partition count is nil/zero.
|
|
50
|
+
return RD_KAFKA_PARTITION_UA unless partition_count&.nonzero?
|
|
51
|
+
|
|
52
|
+
str_ptr = str.empty? ? FFI::MemoryPointer::NULL : FFI::MemoryPointer.from_string(str)
|
|
53
|
+
method_name = PARTITIONERS.fetch(partitioner) do
|
|
54
|
+
raise Rdkafka::Config::ConfigError.new("Unknown partitioner: #{partitioner}")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
public_send(method_name, topic_ptr, str_ptr, partition_key_length(str), partition_count, nil, nil)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Partition key length as the character count (legacy default).
|
|
61
|
+
#
|
|
62
|
+
# @param str [String] the partition key string
|
|
63
|
+
# @return [Integer]
|
|
64
|
+
def self.partition_key_size(str)
|
|
65
|
+
str.size
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Partition key length as the byte count, which is what librdkafka hashes (UTF-8 bytes copied
|
|
69
|
+
# into the key pointer) and what other Kafka clients use.
|
|
70
|
+
#
|
|
71
|
+
# @param str [String] the partition key string
|
|
72
|
+
# @return [Integer]
|
|
73
|
+
def self.partition_key_bytesize(str)
|
|
74
|
+
str.bytesize
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Length of the partition key passed to librdkafka. Aliased to one of the methods above by
|
|
78
|
+
# `Rdkafka::Config.partitioner_key_uses_bytesize=`, so the per-message path does not check the
|
|
79
|
+
# setting on every call.
|
|
80
|
+
singleton_class.alias_method :partition_key_length, :partition_key_size
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Bindings
|
|
5
|
+
# Share consumer (KIP-932, preview)
|
|
6
|
+
#
|
|
7
|
+
# The share consumer is a distinct librdkafka handle type (rd_kafka_share_t) created with
|
|
8
|
+
# rd_kafka_share_consumer_new instead of rd_kafka_new. It is single-threaded by design and
|
|
9
|
+
# librdkafka itself rejects concurrent access with RD_KAFKA_RESP_ERR__CONFLICT.
|
|
10
|
+
|
|
11
|
+
# Minimal mirror of the head of librdkafka's `struct rd_kafka_share_s`, whose first member is
|
|
12
|
+
# the wrapped `rd_kafka_t` (`rkshare_rk`). `rd_kafka_share_t` has no public accessors of its
|
|
13
|
+
# own - not even for the client name - but the handle it wraps is a normal `rd_kafka_t` and is
|
|
14
|
+
# the very handle librdkafka passes to the statistics, error and OAuthBearer callbacks. Reading
|
|
15
|
+
# it lets a share consumer report a name that matches its statistics `name` field, which
|
|
16
|
+
# `rd_kafka_name` cannot do when handed the `rd_kafka_share_t` directly (it would read an
|
|
17
|
+
# unrelated field and return garbage). This mirrors how the gem already maps other librdkafka
|
|
18
|
+
# structs by layout for the pinned librdkafka version.
|
|
19
|
+
class NativeShareConsumer < FFI::Struct
|
|
20
|
+
layout :rkshare_rk, :pointer
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Acknowledge types for share consumer records
|
|
24
|
+
RD_KAFKA_SHARE_ACKNOWLEDGE_TYPE_ACCEPT = 1
|
|
25
|
+
RD_KAFKA_SHARE_ACKNOWLEDGE_TYPE_RELEASE = 2
|
|
26
|
+
RD_KAFKA_SHARE_ACKNOWLEDGE_TYPE_REJECT = 3
|
|
27
|
+
|
|
28
|
+
attach_function :rd_kafka_share_consumer_new, [:pointer, :pointer, :size_t], :pointer
|
|
29
|
+
attach_function :rd_kafka_share_consumer_close, [:pointer], :pointer, blocking: true
|
|
30
|
+
attach_function :rd_kafka_share_consumer_closed, [:pointer], :int
|
|
31
|
+
attach_function :rd_kafka_share_destroy, [:pointer], :pointer, blocking: true
|
|
32
|
+
attach_function :rd_kafka_share_set_log_queue, [:pointer, :pointer], :pointer
|
|
33
|
+
|
|
34
|
+
attach_function :rd_kafka_share_subscribe, [:pointer, :pointer], :int, blocking: true
|
|
35
|
+
attach_function :rd_kafka_share_unsubscribe, [:pointer], :int, blocking: true
|
|
36
|
+
attach_function :rd_kafka_share_subscription, [:pointer, :pointer], :int, blocking: true
|
|
37
|
+
|
|
38
|
+
attach_function :rd_kafka_share_poll, [:pointer, :int, :pointer], :pointer, blocking: true
|
|
39
|
+
attach_function :rd_kafka_messages_count, [:pointer], :size_t
|
|
40
|
+
attach_function :rd_kafka_messages_get, [:pointer, :size_t], :pointer
|
|
41
|
+
attach_function :rd_kafka_messages_destroy, [:pointer], :void
|
|
42
|
+
attach_function :rd_kafka_message_delivery_count, [:pointer], :int16
|
|
43
|
+
|
|
44
|
+
# The by-coordinates acknowledge variant is the only one we bind: Ruby messages are copies
|
|
45
|
+
# that do not retain the native rd_kafka_message_t pointer, so the message-pointer variants
|
|
46
|
+
# (rd_kafka_share_acknowledge / rd_kafka_share_acknowledge_type) cannot be used safely here.
|
|
47
|
+
attach_function :rd_kafka_share_acknowledge_offset, [:pointer, :string, :int32, :int64, :int], :int
|
|
48
|
+
|
|
49
|
+
attach_function :rd_kafka_share_commit_sync, [:pointer, :int, :pointer], :pointer, blocking: true
|
|
50
|
+
attach_function :rd_kafka_share_commit_async, [:pointer], :pointer
|
|
51
|
+
|
|
52
|
+
callback :share_acknowledgement_commit_cb, [:pointer, :pointer, :int, :pointer], :void
|
|
53
|
+
attach_function :rd_kafka_share_set_acknowledgement_commit_cb, [:pointer, :share_acknowledgement_commit_cb, :pointer], :pointer
|
|
54
|
+
|
|
55
|
+
# Accessors for the rd_kafka_share_partition_offsets_list_t handed to the acknowledgement
|
|
56
|
+
# commit callback. The list is owned by librdkafka for the duration of the callback: read it
|
|
57
|
+
# inside the callback only, never destroy or retain it.
|
|
58
|
+
attach_function :rd_kafka_share_partition_offsets_list_count, [:pointer], :size_t
|
|
59
|
+
attach_function :rd_kafka_share_partition_offsets_list_get, [:pointer, :size_t], :pointer
|
|
60
|
+
attach_function :rd_kafka_share_partition_offsets_partition, [:pointer], :pointer
|
|
61
|
+
attach_function :rd_kafka_share_partition_offsets_offsets, [:pointer], :pointer
|
|
62
|
+
attach_function :rd_kafka_share_partition_offsets_offsets_cnt, [:pointer], :size_t
|
|
63
|
+
|
|
64
|
+
attach_function :rd_kafka_share_oauthbearer_set_token, [:pointer, :string, :int64, :string, :pointer, :size_t, :pointer, :size_t], :int
|
|
65
|
+
attach_function :rd_kafka_share_oauthbearer_set_token_failure, [:pointer, :string], :int
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Bindings
|
|
5
|
+
# FFI struct representing a Kafka message (rd_kafka_message_t)
|
|
6
|
+
class Message < FFI::Struct
|
|
7
|
+
layout :err, :int,
|
|
8
|
+
:rkt, :pointer,
|
|
9
|
+
:partition, :int32,
|
|
10
|
+
:payload, :pointer,
|
|
11
|
+
:len, :size_t,
|
|
12
|
+
:key, :pointer,
|
|
13
|
+
:key_len, :size_t,
|
|
14
|
+
:offset, :int64,
|
|
15
|
+
:_private, :pointer
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# FFI struct representing a topic partition (rd_kafka_topic_partition_t)
|
|
19
|
+
class TopicPartition < FFI::Struct
|
|
20
|
+
layout :topic, :string,
|
|
21
|
+
:partition, :int32,
|
|
22
|
+
:offset, :int64,
|
|
23
|
+
:metadata, :pointer,
|
|
24
|
+
:metadata_size, :size_t,
|
|
25
|
+
:opaque, :pointer,
|
|
26
|
+
:err, :int,
|
|
27
|
+
:_private, :pointer
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# FFI struct representing a topic partition list (rd_kafka_topic_partition_list_t)
|
|
31
|
+
class TopicPartitionList < FFI::Struct
|
|
32
|
+
layout :cnt, :int,
|
|
33
|
+
:size, :int,
|
|
34
|
+
:elems, :pointer
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# FFI struct representing a config resource (rd_kafka_ConfigResource_t)
|
|
38
|
+
# Structs for management of configurations. Each configuration is attached to a resource
|
|
39
|
+
# and one resource can have many configuration details. Each resource will also have
|
|
40
|
+
# separate errors results if obtaining configuration was not possible for any reason
|
|
41
|
+
class ConfigResource < FFI::Struct
|
|
42
|
+
layout :type, :int,
|
|
43
|
+
:name, :string
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# FFI struct for error description (rd_kafka_err_desc)
|
|
47
|
+
class NativeErrorDesc < FFI::Struct
|
|
48
|
+
layout :code, :int,
|
|
49
|
+
:name, :pointer,
|
|
50
|
+
:desc, :pointer
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# FFI struct for native error (rd_kafka_error_t)
|
|
54
|
+
class NativeError < FFI::Struct
|
|
55
|
+
layout :code, :int32,
|
|
56
|
+
:errstr, :pointer,
|
|
57
|
+
:fatal, :u_int8_t,
|
|
58
|
+
:retriable, :u_int8_t,
|
|
59
|
+
:txn_requires_abort, :u_int8_t
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|