rdkafka 0.29.0 → 0.29.1
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 +33 -24
- data/README.md +2 -2
- data/bin/verify_kafka_warnings +5 -0
- data/docker-compose-ssl.yml +3 -0
- data/docker-compose.yml +3 -0
- data/lib/rdkafka/admin/create_acl_report.rb +2 -1
- data/lib/rdkafka/admin/delete_records_handle.rb +31 -0
- data/lib/rdkafka/admin/delete_records_report.rb +25 -0
- data/lib/rdkafka/admin/describe_acl_report.rb +2 -1
- data/lib/rdkafka/admin/list_consumer_groups_handle.rb +31 -0
- data/lib/rdkafka/admin/list_consumer_groups_report.rb +83 -0
- data/lib/rdkafka/admin/list_offsets_report.rb +5 -2
- data/lib/rdkafka/admin.rb +178 -117
- data/lib/rdkafka/bindings.rb +52 -12
- data/lib/rdkafka/callbacks/delete_records_handler.rb +38 -0
- data/lib/rdkafka/callbacks/list_consumer_groups_handler.rb +39 -0
- data/lib/rdkafka/callbacks.rb +4 -2
- data/lib/rdkafka/config.rb +24 -17
- data/lib/rdkafka/consumer/topic_partition_list.rb +14 -8
- data/lib/rdkafka/consumer.rb +103 -34
- data/lib/rdkafka/defaults.rb +5 -7
- data/lib/rdkafka/helpers/list_offsets.rb +127 -0
- data/lib/rdkafka/helpers/oauth.rb +10 -5
- data/lib/rdkafka/native_kafka.rb +20 -7
- data/lib/rdkafka/producer/delivery_handle.rb +1 -2
- data/lib/rdkafka/producer.rb +25 -17
- data/lib/rdkafka/version.rb +1 -1
- data/lib/rdkafka.rb +7 -0
- data/package-lock.json +3 -3
- metadata +9 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9df14d82195673f4747cc9a5d20eeb705a547295b1fa25f6554a5f9fac415ff0
|
|
4
|
+
data.tar.gz: d98858ef1d0c6694acd2de1726e0727a17aae1694adf2d75ee9890bdf8608d57
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 82715ad307088ce3559789b9445c968fb1dcbfa2e87ba70b8e90c786ff92066c37497b8592153e8512ed297706a8499d38e2c04754129390665478a3174bcf0e
|
|
7
|
+
data.tar.gz: 00fd0221b7afde5cf110437d3b83f7672b820b3ebc596d2ad7126c248f31bb89b35d29ced75c24da0a17af2828a2fc4f7feb4397cdcfe6d04bf78882f2ee02b6
|
data/CHANGELOG.md
CHANGED
|
@@ -1,37 +1,46 @@
|
|
|
1
1
|
# Rdkafka Changelog
|
|
2
2
|
|
|
3
|
+
## 0.29.1 (2026-09-04)
|
|
4
|
+
- [Enhancement] Add `Admin#delete_records` to delete all messages in a partition up to a given offset.
|
|
5
|
+
- [Enhancement] Add `Admin#list_consumer_groups` to list the cluster's consumer groups.
|
|
6
|
+
- [Enhancement] Name the failing topic and partition in the `RdkafkaError` raised for per-partition `list_offsets` errors.
|
|
7
|
+
- [Enhancement] Add `Consumer#list_offsets` to query partition offsets on an existing consumer handle without opening a dedicated admin connection.
|
|
8
|
+
- [Fix] Make `NativeKafka#close` fork-aware so a forked child no longer segfaults on exit.
|
|
9
|
+
- [Fix] Stabilize the `to_native_tpl` leak integration spec.
|
|
10
|
+
- [Fix] Stabilize the flaky partitions count cache statistics spec.
|
|
11
|
+
|
|
3
12
|
## 0.29.0 (2026-07-10)
|
|
4
13
|
- [Enhancement] Bump librdkafka to `2.14.2`
|
|
5
14
|
- [Enhancement] Add `Consumer#metadata` and `Producer#metadata`, mirroring `Admin#metadata`, so cluster/topic metadata can be fetched from an existing consumer or producer handle without opening a dedicated admin connection.
|
|
6
15
|
- [Enhancement] Support offset-commit metadata: `Consumer#store_offset(message, metadata)` stores an optional metadata string alongside the offset, `Consumer::Partition#metadata` exposes it, and `TopicPartitionList` marshals it to and from the native list (read back via `Consumer#committed`).
|
|
7
|
-
- [
|
|
8
|
-
- [
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
11
|
-
- [Fix]
|
|
12
|
-
- [Fix]
|
|
16
|
+
- [Enhancement] Expose `replicas` and `isrs` (in-sync replica broker ids) on each partition in topic metadata; both were previously dropped from the `Metadata#topics` partition hashes.
|
|
17
|
+
- [Enhancement] Extract the admin background-event result handlers into one class per operation under `lib/rdkafka/callbacks/`. Internal reorganization with no API or behavior change.
|
|
18
|
+
- [Enhancement] Reuse per-thread scratch pointers in `Consumer::Headers.from_native`, removing the per-message native allocations from the consumer hot path.
|
|
19
|
+
- [Enhancement] Remove the unused `DeliveryHandle` `:topic_name` struct field and its per-message allocation. Use `DeliveryHandle#topic` or `DeliveryReport#topic_name`, both unchanged.
|
|
20
|
+
- [Fix] Cache the partition count for a missing topic, so `produce` with a `partition_key` to a missing topic no longer re-runs a blocking metadata query on every message.
|
|
21
|
+
- [Fix] Let `PartitionsCountCache` adopt a lower partition count once the cached entry has expired, so a topic recreated with fewer partitions no longer fails `produce` until process restart.
|
|
22
|
+
- [Fix] Surface per-message build errors inline in `Consumer#poll_batch`/`#poll_batch_nb` instead of discarding the batch, preserving the messages that built successfully.
|
|
23
|
+
- [Fix] Bound the `Metadata` retry loop by a ~5s wall-clock budget with a floor of 3 attempts, cap the backoff at 1s, and stop overwriting the request timeout with the backoff value, which could block a synchronous fetch for minutes.
|
|
24
|
+
- [Fix] Synchronize `AbstractHandle::REGISTRY` mutations with a mutex, which could otherwise lose a write on JRuby and leave a handle unregistered or leaked.
|
|
25
|
+
- [Fix] Fix the NULL background-queue cleanup branches in `Admin#delete_group`, `Admin#delete_acl` and `Admin#describe_acl`, which raised a `NameError` and leaked the native request object instead of raising `ConfigError`.
|
|
13
26
|
- [Fix] Actually populate `ConfigBindingResult#synonyms`. The synonym loop built the synonym binding objects and discarded them, so `#synonyms` was always an empty array; they are now appended.
|
|
14
|
-
- [Fix] Stop leaking the native `rd_kafka_topic_conf_t` in `Producer#set_topic_config` when a per-topic config value is rejected.
|
|
27
|
+
- [Fix] Stop leaking the native `rd_kafka_topic_conf_t` in `Producer#set_topic_config` when a per-topic config value is rejected.
|
|
15
28
|
- [Fix] Add the missing `closed_consumer_check` to `Consumer#position`, the only public consumer method without one; calling it on a closed consumer now raises a consistent `ClosedConsumerError` instead of failing deeper in the call.
|
|
16
29
|
- [Fix] Guard the OAuthBearer token refresh callback against a NULL client pointer before calling `rd_kafka_name` on it.
|
|
17
|
-
- [Fix] Make the `Consumer` GC finalizer close the consumer and destroy its consumer queue, not just the native client
|
|
18
|
-
- [Fix] Free the librdkafka-allocated string in `Consumer#cluster_id` and `Consumer#member_id
|
|
19
|
-
- [Fix] Attach `rd_kafka_query_watermark_offsets` with `blocking: true` so it releases the GVL
|
|
20
|
-
- [Fix] Stop leaking the native `rd_kafka_conf_t` when client creation fails
|
|
21
|
-
- [Fix] Stop `Metadata` from leaking the native metadata struct
|
|
22
|
-
- [Fix] Stop `Producer#produce` from orphaning the delivery handle in the process-global registry when it fails after registering it.
|
|
23
|
-
- [Fix] Guard the message delivery callback so a raising user `delivery_callback` can no longer
|
|
24
|
-
- [Fix] Stop
|
|
30
|
+
- [Fix] Make the `Consumer` GC finalizer close the consumer and destroy its consumer queue, not just the native client, preventing a hang or leak when a consumer is collected without an explicit `close`.
|
|
31
|
+
- [Fix] Free the librdkafka-allocated string in `Consumer#cluster_id` and `Consumer#member_id`, and fix the `rd_kafka_clusterid` arity. `Consumer#cluster_id` now accepts a `timeout_ms`.
|
|
32
|
+
- [Fix] Attach `rd_kafka_query_watermark_offsets` with `blocking: true` so it releases the GVL; it previously froze every other Ruby thread for up to `timeout_ms`.
|
|
33
|
+
- [Fix] Stop leaking the native `rd_kafka_conf_t` when client creation fails, a multi-KB leak per failed attempt for supervisors retrying on transient SASL/SSL misconfiguration.
|
|
34
|
+
- [Fix] Stop `Metadata` from leaking the native metadata struct on every retried fetch; each attempt now frees its own native resources.
|
|
35
|
+
- [Fix] Stop `Producer#produce` from orphaning the delivery handle in the process-global registry when it fails after registering it.
|
|
36
|
+
- [Fix] Guard the message delivery callback so a raising user `delivery_callback` can no longer leave the handle locked or crash the producer; exceptions are now logged and swallowed.
|
|
37
|
+
- [Fix] Stop `describe_configs`, `incremental_alter_configs` and `list_offsets` from leaking handles and native resources when their arguments are rejected; all three now validate input before allocating.
|
|
25
38
|
- [Fix] Destroy the native topic-partition list in `TopicPartitionList#to_native_tpl` when population fails partway (e.g. an invalid partition). The caller-owned list was leaked on any exception mid-build; it is now destroyed before the error propagates.
|
|
26
|
-
- [Fix] Raise instead of silently dropping a rejected `incremental_alter_configs` entry
|
|
27
|
-
- [Fix] Allocate the admin result-count out-parameter as `:size_t` instead of `:int32
|
|
28
|
-
- [Fix] Stabilize the flaky `Consumer#lag` "calculates the consumer lag" spec on overloaded CI
|
|
29
|
-
- [
|
|
30
|
-
- [Fix]
|
|
31
|
-
- [Enhancement] Extract the admin background-event result handlers into one class per operation under `lib/rdkafka/callbacks/` (`CreateTopicHandler`, `DescribeConfigsHandler`, etc., all subclasses of `Callbacks::BaseHandler`). `Callbacks::BackgroundEventCallback` is now a thin dispatcher that maps the event type to its handler and destroys the event. Purely internal reorganization (`Rdkafka::Callbacks` is private) with no behavior or API change.
|
|
32
|
-
- [Fix] Destroy admin API background events after processing. librdkafka requires the application to destroy each background event, but `rd_kafka_event_destroy` was never called (nor even bound), so every admin operation leaked its entire result event with all result arrays and strings. Reports are now built inside the callback (copying event-owned memory into Ruby objects) before the event is destroyed, and `DescribeConfigsReport`/`IncrementalAlterConfigsReport` no longer destroy the event-owned ConfigResource array, which also fixes a double free on repeated `wait` calls on the same handle. As part of this, the internal FFI struct fields on admin operation handles (e.g. `handle[:error_string]`, `handle[:result_name]`, `handle[:config_entries]`, `handle[:response_string]`, `handle[:matching_acls]`) were removed; they were never part of the public API (use `handle.wait` and the returned report objects, whose interfaces are unchanged).
|
|
33
|
-
- [Enhancement] Reuse per-thread scratch pointers in `Consumer::Headers.from_native` instead of allocating them for every consumed message. Previously each message paid one native pointer allocation just to check for headers and three more when headers were present; now the scratch pointers are allocated once per thread/fiber and reused, removing all per-message native scratch allocations from the consumer hot path.
|
|
34
|
-
- [Enhancement] Remove the unused `DeliveryHandle` `:topic_name` struct field and the per-message allocation that populated it. The delivery callback copied the topic name into a native `FFI::MemoryPointer` on every delivered message, retained for the lifetime of the handle, yet nothing ever read it: the topic is already available via `DeliveryHandle#topic` (a Ruby attribute set during `produce`) and `DeliveryReport#topic_name`, both of which work exactly as before.
|
|
39
|
+
- [Fix] Raise instead of silently dropping a rejected `incremental_alter_configs` entry, which previously left the alter request reporting success.
|
|
40
|
+
- [Fix] Allocate the admin result-count out-parameter as `:size_t` instead of `:int32`, fixing a 4-byte overflow on every admin result parse.
|
|
41
|
+
- [Fix] Stabilize the flaky `Consumer#lag` "calculates the consumer lag" spec on overloaded CI.
|
|
42
|
+
- [Fix] Resolve admin operation handles from the event error when an operation fails at the operation level (e.g. brokers unreachable), instead of blocking until `wait` timed out and discarding the real error.
|
|
43
|
+
- [Fix] Destroy admin API background events after processing; they were never destroyed, so every admin operation leaked its whole result event. The internal FFI struct fields on admin handles were removed as part of this - use `handle.wait` and the returned report objects, whose interfaces are unchanged.
|
|
35
44
|
|
|
36
45
|
## 0.28.0 (2026-06-03)
|
|
37
46
|
- [Enhancement] Bump librdkafka to `2.14.1`
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Rdkafka
|
|
2
2
|
|
|
3
|
-
[](https://github.com/karafka/rdkafka-ruby/actions/workflows/
|
|
3
|
+
[](https://github.com/karafka/rdkafka-ruby/actions/workflows/ci_linux_ubuntu_x86_64_gnu.yml)
|
|
4
4
|
[](https://badge.fury.io/rb/rdkafka)
|
|
5
5
|
[](https://slack.karafka.io)
|
|
6
6
|
|
|
@@ -174,7 +174,7 @@ bundle exec rake produce_messages
|
|
|
174
174
|
| 0.21.x (2025-02-13) | 2.8.0 (2025-01-07) | yes |
|
|
175
175
|
| 0.20.0 (2025-01-07) | 2.6.1 (2024-11-18) | yes |
|
|
176
176
|
| 0.19.0 (2024-10-01) | 2.5.3 (2024-09-02) | yes |
|
|
177
|
-
| 0.18.0 (2024-09-02) | 2.5.0 (2024-
|
|
177
|
+
| 0.18.0 (2024-09-02) | 2.5.0 (2024-07-10) | yes |
|
|
178
178
|
| 0.17.0 (2024-08-03) | 2.4.0 (2024-05-07) | no |
|
|
179
179
|
| 0.16.0 (2024-06-13) | 2.3.0 (2023-10-25) | no |
|
|
180
180
|
| 0.15.0 (2023-12-03) | 2.3.0 (2023-10-25) | no |
|
data/bin/verify_kafka_warnings
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
# Only specified warnings are allowed, all others should trigger failure
|
|
5
5
|
|
|
6
6
|
allowed_patterns=(
|
|
7
|
+
# Enabling share groups (KIP-932) requires "share" in group.coordinator.rebalance.protocols
|
|
8
|
+
# on cp-kafka 8.3.0 (Kafka 4.x). That mechanism is deprecated in favour of the share.version
|
|
9
|
+
# feature flag (Kafka 5.0), but is still functionally required to enable share groups in this
|
|
10
|
+
# version, so the broker logs this deprecation warning on every startup. Expected here.
|
|
11
|
+
"group.coordinator.rebalance.protocols. is deprecated"
|
|
7
12
|
"Performing controller activation"
|
|
8
13
|
"registered with feature metadata.version"
|
|
9
14
|
"Replayed TopicRecord for"
|
data/docker-compose-ssl.yml
CHANGED
|
@@ -22,6 +22,9 @@ services:
|
|
|
22
22
|
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false'
|
|
23
23
|
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
|
|
24
24
|
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
|
|
25
|
+
KAFKA_GROUP_COORDINATOR_REBALANCE_PROTOCOLS: 'classic,consumer,share'
|
|
26
|
+
KAFKA_SHARE_COORDINATOR_STATE_TOPIC_REPLICATION_FACTOR: 1
|
|
27
|
+
KAFKA_SHARE_COORDINATOR_STATE_TOPIC_MIN_ISR: 1
|
|
25
28
|
KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: "true"
|
|
26
29
|
KAFKA_AUTHORIZER_CLASS_NAME: org.apache.kafka.metadata.authorizer.StandardAuthorizer
|
|
27
30
|
|
data/docker-compose.yml
CHANGED
|
@@ -21,5 +21,8 @@ services:
|
|
|
21
21
|
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false'
|
|
22
22
|
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
|
|
23
23
|
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
|
|
24
|
+
KAFKA_GROUP_COORDINATOR_REBALANCE_PROTOCOLS: 'classic,consumer,share'
|
|
25
|
+
KAFKA_SHARE_COORDINATOR_STATE_TOPIC_REPLICATION_FACTOR: 1
|
|
26
|
+
KAFKA_SHARE_COORDINATOR_STATE_TOPIC_MIN_ISR: 1
|
|
24
27
|
KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: "true"
|
|
25
28
|
KAFKA_AUTHORIZER_CLASS_NAME: org.apache.kafka.metadata.authorizer.StandardAuthorizer
|
|
@@ -4,7 +4,8 @@ module Rdkafka
|
|
|
4
4
|
class Admin
|
|
5
5
|
# Report for create ACL operation result
|
|
6
6
|
class CreateAclReport
|
|
7
|
-
# Upon successful creation of Acl RD_KAFKA_RESP_ERR_NO_ERROR - 0 is returned as
|
|
7
|
+
# Upon successful creation of Acl RD_KAFKA_RESP_ERR_NO_ERROR - 0 is returned as
|
|
8
|
+
# rdkafka_response
|
|
8
9
|
# @return [Integer]
|
|
9
10
|
attr_reader :rdkafka_response
|
|
10
11
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
class Admin
|
|
5
|
+
# Handle for delete records operation
|
|
6
|
+
class DeleteRecordsHandle < AbstractHandle
|
|
7
|
+
layout :pending, :bool,
|
|
8
|
+
:response, :int
|
|
9
|
+
|
|
10
|
+
# @return [String] the name of the operation
|
|
11
|
+
def operation_name
|
|
12
|
+
"delete records"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @return [DeleteRecordsReport] report prepared by the background event callback, with the
|
|
16
|
+
# post-deletion low-watermark offsets (or per-partition errors)
|
|
17
|
+
def create_result
|
|
18
|
+
prepared_result
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Raises an error if the operation failed
|
|
22
|
+
# @raise [RdkafkaError]
|
|
23
|
+
def raise_error
|
|
24
|
+
raise RdkafkaError.new(
|
|
25
|
+
self[:response],
|
|
26
|
+
broker_message: broker_message
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
class Admin
|
|
5
|
+
# Report for delete records operation result
|
|
6
|
+
class DeleteRecordsReport
|
|
7
|
+
# Per-partition results. Each partition's `offset` is the post-deletion low-watermark (the
|
|
8
|
+
# smallest available offset of all live replicas) and its `err` carries the per-partition
|
|
9
|
+
# error code, if deletion failed for that partition.
|
|
10
|
+
# @return [Rdkafka::Consumer::TopicPartitionList]
|
|
11
|
+
attr_reader :offsets
|
|
12
|
+
|
|
13
|
+
# @param result_ptr [FFI::Pointer] pointer to the `rd_kafka_DeleteRecords_result_t`
|
|
14
|
+
def initialize(result_ptr)
|
|
15
|
+
@offsets = Rdkafka::Consumer::TopicPartitionList.new
|
|
16
|
+
|
|
17
|
+
return if result_ptr.null?
|
|
18
|
+
|
|
19
|
+
native_tpl = Bindings.rd_kafka_DeleteRecords_result_offsets(result_ptr)
|
|
20
|
+
|
|
21
|
+
@offsets = Rdkafka::Consumer::TopicPartitionList.from_native_tpl(native_tpl)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -4,7 +4,8 @@ module Rdkafka
|
|
|
4
4
|
class Admin
|
|
5
5
|
# Report for describe ACL operation result
|
|
6
6
|
class DescribeAclReport
|
|
7
|
-
# acls that exists in the cluster for the resource_type, resource_name and pattern_type
|
|
7
|
+
# acls that exists in the cluster for the resource_type, resource_name and pattern_type
|
|
8
|
+
# filters provided in the request.
|
|
8
9
|
# @return [Rdkafka::Bindings::AclBindingResult] array of matching acls.
|
|
9
10
|
attr_reader :acls
|
|
10
11
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
class Admin
|
|
5
|
+
# Handle for list consumer groups operation
|
|
6
|
+
class ListConsumerGroupsHandle < AbstractHandle
|
|
7
|
+
layout :pending, :bool,
|
|
8
|
+
:response, :int
|
|
9
|
+
|
|
10
|
+
# @return [String] the name of the operation
|
|
11
|
+
def operation_name
|
|
12
|
+
"list consumer groups"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @return [ListConsumerGroupsReport] report prepared by the background event callback, with
|
|
16
|
+
# the listed consumer groups.
|
|
17
|
+
def create_result
|
|
18
|
+
prepared_result
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Raises an error if the operation failed
|
|
22
|
+
# @raise [RdkafkaError]
|
|
23
|
+
def raise_error
|
|
24
|
+
raise RdkafkaError.new(
|
|
25
|
+
self[:response],
|
|
26
|
+
broker_message: broker_message
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
class Admin
|
|
5
|
+
# Report for list consumer groups operation result
|
|
6
|
+
class ListConsumerGroupsReport
|
|
7
|
+
# Consumer groups listed cluster-wide. Each entry is a hash with:
|
|
8
|
+
# - `:group_id` [String] the consumer group id
|
|
9
|
+
# - `:is_simple_consumer_group` [Boolean] `true` for a "simple" consumer group - one that
|
|
10
|
+
# assigns partitions manually (via `assign`) and uses Kafka only for offset storage,
|
|
11
|
+
# rather than joining the group-management protocol and letting Kafka assign partitions
|
|
12
|
+
# and rebalance automatically (`subscribe`). Simple groups have no members from the
|
|
13
|
+
# broker's point of view, so they never rebalance.
|
|
14
|
+
# - `:state` [Integer] the group state as a `Bindings::RD_KAFKA_CONSUMER_GROUP_STATE_*`
|
|
15
|
+
# code, one of: `RD_KAFKA_CONSUMER_GROUP_STATE_UNKNOWN`,
|
|
16
|
+
# `RD_KAFKA_CONSUMER_GROUP_STATE_PREPARING_REBALANCE`,
|
|
17
|
+
# `RD_KAFKA_CONSUMER_GROUP_STATE_COMPLETING_REBALANCE`,
|
|
18
|
+
# `RD_KAFKA_CONSUMER_GROUP_STATE_STABLE`, `RD_KAFKA_CONSUMER_GROUP_STATE_DEAD`,
|
|
19
|
+
# `RD_KAFKA_CONSUMER_GROUP_STATE_EMPTY`
|
|
20
|
+
# - `:state_name` [String] human-readable name of that state (e.g. `"Stable"`, `"Empty"`)
|
|
21
|
+
# @return [Array<Hash>]
|
|
22
|
+
attr_reader :groups
|
|
23
|
+
|
|
24
|
+
# Per-broker errors reported alongside the (partial) group listing. `ListConsumerGroups`
|
|
25
|
+
# fans out to every broker and returns valid groups and errors separately, so a broker
|
|
26
|
+
# being unreachable does not discard the groups the reachable brokers returned.
|
|
27
|
+
# @return [Array<RdkafkaError>]
|
|
28
|
+
attr_reader :errors
|
|
29
|
+
|
|
30
|
+
# @param result_ptr [FFI::Pointer] pointer to the `rd_kafka_ListConsumerGroups_result_t`
|
|
31
|
+
def initialize(result_ptr)
|
|
32
|
+
@groups = []
|
|
33
|
+
@errors = []
|
|
34
|
+
|
|
35
|
+
return if result_ptr.null?
|
|
36
|
+
|
|
37
|
+
extract_groups(result_ptr)
|
|
38
|
+
extract_errors(result_ptr)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
# @param result_ptr [FFI::Pointer] pointer to the result
|
|
44
|
+
def extract_groups(result_ptr)
|
|
45
|
+
count_ptr = FFI::MemoryPointer.new(:size_t)
|
|
46
|
+
array_ptr = Bindings.rd_kafka_ListConsumerGroups_result_valid(result_ptr, count_ptr)
|
|
47
|
+
|
|
48
|
+
return if array_ptr.null?
|
|
49
|
+
|
|
50
|
+
array_ptr.read_array_of_pointer(count_ptr.read(:size_t)).each do |listing_ptr|
|
|
51
|
+
state = Bindings.rd_kafka_ConsumerGroupListing_state(listing_ptr)
|
|
52
|
+
group_id_ptr = Bindings.rd_kafka_ConsumerGroupListing_group_id(listing_ptr)
|
|
53
|
+
state_name_ptr = Bindings.rd_kafka_consumer_group_state_name(state)
|
|
54
|
+
|
|
55
|
+
@groups << {
|
|
56
|
+
group_id: group_id_ptr.null? ? nil : group_id_ptr.read_string,
|
|
57
|
+
is_simple_consumer_group:
|
|
58
|
+
Bindings.rd_kafka_ConsumerGroupListing_is_simple_consumer_group(listing_ptr) != 0,
|
|
59
|
+
state: state,
|
|
60
|
+
state_name: state_name_ptr.null? ? nil : state_name_ptr.read_string
|
|
61
|
+
}
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# @param result_ptr [FFI::Pointer] pointer to the result
|
|
66
|
+
def extract_errors(result_ptr)
|
|
67
|
+
count_ptr = FFI::MemoryPointer.new(:size_t)
|
|
68
|
+
array_ptr = Bindings.rd_kafka_ListConsumerGroups_result_errors(result_ptr, count_ptr)
|
|
69
|
+
|
|
70
|
+
return if array_ptr.null?
|
|
71
|
+
|
|
72
|
+
array_ptr.read_array_of_pointer(count_ptr.read(:size_t)).each do |error_ptr|
|
|
73
|
+
string_ptr = Bindings.rd_kafka_error_string(error_ptr)
|
|
74
|
+
|
|
75
|
+
@errors << RdkafkaError.new(
|
|
76
|
+
Bindings.rd_kafka_error_code(error_ptr),
|
|
77
|
+
broker_message: string_ptr.null? ? nil : string_ptr.read_string
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -36,7 +36,7 @@ module Rdkafka
|
|
|
36
36
|
|
|
37
37
|
# Validates the partition result and raises an error if invalid
|
|
38
38
|
# @param result_info_ptr [FFI::Pointer] pointer to the result info
|
|
39
|
-
# @raise [RdkafkaError] when the partition has an error
|
|
39
|
+
# @raise [RdkafkaError] when the partition has an error, naming the failing partition
|
|
40
40
|
def validate!(result_info_ptr)
|
|
41
41
|
tp_ptr = Bindings.rd_kafka_ListOffsetsResultInfo_topic_partition(result_info_ptr)
|
|
42
42
|
tp = Bindings::TopicPartition.new(tp_ptr)
|
|
@@ -44,7 +44,10 @@ module Rdkafka
|
|
|
44
44
|
|
|
45
45
|
return if code.zero?
|
|
46
46
|
|
|
47
|
-
raise RdkafkaError.new(
|
|
47
|
+
raise RdkafkaError.new(
|
|
48
|
+
code,
|
|
49
|
+
"Error querying offsets for partition #{tp[:partition]} of '#{tp[:topic]}'"
|
|
50
|
+
)
|
|
48
51
|
end
|
|
49
52
|
end
|
|
50
53
|
end
|