karafka-rdkafka 0.31.0 → 0.32.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 +100 -35
- data/README.md +14 -6
- data/dist/patches/rdkafka_cgrp_late_assignment_after_leave.patch +33 -0
- data/dist/patches/rdkafka_offset_fetch_no_cgrp.patch +21 -0
- data/dist/patches/rdkafka_retry_msgq_backoff_overflow.patch +30 -0
- data/karafka-rdkafka.gemspec +4 -3
- data/lib/rdkafka/abstract_handle.rb +26 -11
- 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/config_binding_result.rb +8 -0
- 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_report.rb +3 -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 +180 -10
- data/lib/rdkafka/bindings/admin/configs.rb +12 -1
- data/lib/rdkafka/bindings/admin.rb +14 -0
- data/lib/rdkafka/bindings/callbacks.rb +16 -9
- data/lib/rdkafka/bindings/configuration.rb +3 -3
- data/lib/rdkafka/bindings/consumer.rb +44 -2
- data/lib/rdkafka/bindings/errors.rb +1 -1
- data/lib/rdkafka/bindings/handle.rb +1 -1
- data/lib/rdkafka/bindings.rb +3 -0
- data/lib/rdkafka/callbacks/list_consumer_group_offsets_handler.rb +62 -0
- data/lib/rdkafka/callbacks.rb +5 -6
- data/lib/rdkafka/config.rb +70 -0
- data/lib/rdkafka/consumer/allocator.rb +0 -2
- data/lib/rdkafka/consumer/topic_partition_list.rb +7 -7
- data/lib/rdkafka/consumer.rb +133 -52
- data/lib/rdkafka/defaults.rb +15 -6
- data/lib/rdkafka/helpers/message_build_error.rb +30 -0
- data/lib/rdkafka/native_kafka.rb +136 -41
- data/lib/rdkafka/producer/partition_count_cache.rb +258 -0
- data/lib/rdkafka/producer.rb +196 -81
- data/lib/rdkafka/share_consumer.rb +75 -38
- data/lib/rdkafka/version.rb +1 -1
- data/lib/rdkafka.rb +6 -2
- data/package-lock.json +3 -3
- data/renovate.json +32 -2
- metadata +31 -24
- data/lib/rdkafka/producer/partitions_count_cache.rb +0 -212
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0e7a2f32d0137177be9a6991bc1dd3ee482fc73aebc3583e89e2fd922cfe3d55
|
|
4
|
+
data.tar.gz: 41ca25929dd3a2f53ec7106f800974171c4df2cd9d706b11a489510d35ae33e4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 884859616aaa15e245689a53053f8e3c8013f26842e65237dbb302f39e13a7eab80f5c745fc7dca6cce9a50aee7d32cb6092f7baf6fbfc91a2ba7da7df9ffa20
|
|
7
|
+
data.tar.gz: 5ce88ad5e9314fe761c2e9d082de817c0ef72b30fba3e980461907c79dbfb0b82c296553c270d2da442aecc28dedb31bc606a3d6e22a1c226d687b567498c749
|
data/CHANGELOG.md
CHANGED
|
@@ -1,20 +1,85 @@
|
|
|
1
1
|
# Rdkafka Changelog
|
|
2
2
|
|
|
3
|
+
## 0.32.1 (2026-11-18)
|
|
4
|
+
- [Change] Take the partition list of `Admin#list_consumer_group_offsets` as the `topic_partition_list:` keyword instead of a positional argument. Its only caller is karafka's admin API, which passes it as a keyword from karafka 2.6.2 (released karafka does not call it).
|
|
5
|
+
- [Change] Return one shared frozen empty array from `Consumer#poll_batch` and `#poll_batch_nb` when no messages arrive, so an empty poll allocates nothing. Code that mutates an empty result now raises `FrozenError`; no Karafka ecosystem gem calls these methods.
|
|
6
|
+
- **[Feature]** Add `#source` and `#source_name` to `describe_configs` config entries and their synonyms, telling a value set on the topic from one inherited from the broker or a built-in default. Ported from rdkafka-ruby (#1120).
|
|
7
|
+
- [Enhancement] Allocate fewer objects per handle: delivery and admin handles share a fixed set of locks instead of creating their own `Mutex` and `ConditionVariable`. Ported from rdkafka-ruby (#1087).
|
|
8
|
+
- [Enhancement] Bump the bundled zlib to `1.4`. Ported from rdkafka-ruby (#1109).
|
|
9
|
+
- [Enhancement] Bump the bundled MIT Kerberos (krb5) to `1.22.3` for security fixes. Ported from rdkafka-ruby (#1119).
|
|
10
|
+
- [Enhancement] Build the bundled zlib with `-O2` in the glibc precompiled gems for faster gzip compression and decompression. Ported from rdkafka-ruby (#1112).
|
|
11
|
+
- [Enhancement] Raise `Rdkafka::Producer::PartitionCountError` from `Producer#partition_count` and `partition_key` produces when the partition count cannot be fetched. It names the topic, keeps the `RdkafkaError` code and has the original error as `cause`.
|
|
12
|
+
- **[Deprecation]** Rename `Producer::PartitionsCountCache`, `Producer.partitions_count_cache` / `.partitions_count_cache=` and `Defaults::PARTITIONS_COUNT_CACHE_TTL_MS` / `PARTITIONS_COUNT_CACHE_STALE_BACKOFF_MS` to their `partition_count` forms. The old names still work but will be removed in v1.0.0. The old methods warn; the old constants are plain aliases and do not warn. Ported from rdkafka-ruby (#1102).
|
|
13
|
+
- [Fix] Keep `close` from hanging forever after a thread using the client was killed (JRuby) or interrupted by `Thread#raise` or `Timeout` (all Rubies). Ported from rdkafka-ruby (#1082).
|
|
14
|
+
- [Fix] Keep `close` from hanging forever after a signal `trap` handler raised while the main thread used the client. Ported from rdkafka-ruby (#1100).
|
|
15
|
+
- [Fix] Keep the shared partition count cache consistent when many threads produce with `partition_key` or call `partition_count` at once. On JRuby it lost topics and raised `NoMethodError`. Ported from rdkafka-ruby (#1078).
|
|
16
|
+
- [Fix] Return `nil` from every `close` call when several threads close one consumer, producer or admin at once, instead of raising `ClosedInnerError` in the later callers. Ported from rdkafka-ruby (#1107).
|
|
17
|
+
- [Fix] Give the error of a message that fails to build (e.g. unreadable headers) its `topic`, `partition` and `offset` in `details` in `Consumer#poll`, `#poll_nb`, `#poll_nb_each`, `#poll_batch` and `#poll_batch_nb`, so the caller can seek back to it instead of losing it.
|
|
18
|
+
- [Fix] Give the error of a message that fails to build its `topic`, `partition` and `offset` in `details` in `ShareConsumer#poll` too, so in explicit acknowledgement mode the caller can acknowledge (release or reject) that record.
|
|
19
|
+
|
|
20
|
+
## 0.32.0 (2026-11-04)
|
|
21
|
+
- **[Feature]** Add `Config#consumer_offset_commit_listener`: its `#on_offsets_committed(error, list)` gets the result of every offset commit when the consumer polls or closes, so an async commit that the broker rejects reaches Ruby instead of only a `COMMITFAIL` log line. Ported from rdkafka-ruby (#1061).
|
|
22
|
+
- **[Feature]** Let the offset commit listener define `#on_offsets_commit_failed(error, list)`, called only for failed commits (not on success or `no_offset`).
|
|
23
|
+
- **[Feature]** Add `Admin#list_consumer_group_offsets` to read the committed offsets of any consumer group without joining it, with a `require_stable_offsets` option.
|
|
24
|
+
- **[Feature]** Add `validate_only:`, `operation_timeout_ms:` and `request_timeout_ms:` keyword options to `Admin#create_topic` and `#create_partitions`, and the two timeouts to `#delete_topic`. A `create_topic` topic config passed without braces keeps working. Ported from rdkafka-ruby (#1092).
|
|
25
|
+
- [Enhancement] Reduce object shape variations of the admin report classes to one shape per class.
|
|
26
|
+
- [Enhancement] Keep `partition_key` produces working during a cluster outage once the topic partition count is known, instead of raising. Ported from rdkafka-ruby (#1039).
|
|
27
|
+
- [Enhancement] Add `Rdkafka::Config.partition_count_cache_ttl_ms=` to set how long `partition_key` produces reuse a cached partition count (default 30 seconds).
|
|
28
|
+
- [Enhancement] Make `Producer#produce` use about 13% less CPU per call. Ported from rdkafka-ruby (#1064).
|
|
29
|
+
- [Enhancement] Allocate fewer objects per delivered message: delivery callback reports reuse the topic String given to `produce`. Ported from rdkafka-ruby (#1066).
|
|
30
|
+
- [Change] Build the precompiled `x86_64-linux-gnu` and `aarch64-linux-gnu` libraries in an Ubuntu 22.04 container to keep the glibc 2.34 floor. Ported from rdkafka-ruby (#1029).
|
|
31
|
+
- [Change] Depend on `mini_portile2` and `rake` only in the source gem, as only it compiles librdkafka. Apps that got `rake` only through this gem must add it to their Gemfile.
|
|
32
|
+
- [Change] Remove the unused `Rdkafka::Defaults::NATIVE_KAFKA_SYNCHRONIZE_SLEEP_INTERVAL_MS`. Ported from rdkafka-ruby (#1055).
|
|
33
|
+
- [Maintenance] Fix a use-after-free in the `client_shutdown_dlclose` integration test that made it crash intermittently after its own unmap.
|
|
34
|
+
- [Maintenance] Stabilize the flaky `Consumer#seek` and `#seek_by` "works when a partition is paused" specs on loaded CI runners.
|
|
35
|
+
- [Maintenance] Stop the `client_shutdown_dlclose` integration test from failing with `Errno::ESRCH`.
|
|
36
|
+
- [Maintenance] Stabilize the flaky `Consumer` "long running consumption" spec.
|
|
37
|
+
- [Maintenance] Drop `pry` from the development bundle and stop requiring it in the spec helper.
|
|
38
|
+
- [Maintenance] Stabilize the flaky `admin_describe_topics` integration test.
|
|
39
|
+
- [Maintenance] Name positional String topic parameters `topic_name`. Callers are not affected. Ported from rdkafka-ruby (#1052).
|
|
40
|
+
- [Maintenance] Name the positional String topic parameters of `Producer::PartitionsCountCache` `topic_name`. Callers are not affected.
|
|
41
|
+
- [Maintenance] Cover with integration tests that coordinator errors on group offset requests do not crash the admin client or a consumer without `group.id`. Ported from rdkafka-ruby (#1044).
|
|
42
|
+
- [Maintenance] Skip the bindings signature parity spec on JRuby, whose FFI does not expose function signatures. Ported from rdkafka-ruby (#1046).
|
|
43
|
+
- [Maintenance] Match the FFI pointer expectations in the consumer specs by address, so they pass on JRuby. Ported from rdkafka-ruby (#1047).
|
|
44
|
+
- [Maintenance] Run the `client_shutdown_dlclose` integration test on JRuby on Linux. Ported from rdkafka-ruby (#1049).
|
|
45
|
+
- [Maintenance] Check the native call balance instead of RSS in the leak integration specs on JRuby. Ported from rdkafka-ruby (#1050).
|
|
46
|
+
- [Maintenance] Give the `Consumer#lag` spec a 30 s list offsets wait.
|
|
47
|
+
- [Maintenance] Give the share group offset reset in the `ShareConsumer` specs a 30 s wait and always close its admin.
|
|
48
|
+
- [Maintenance] Define `Consumer.finalizer` and `Consumer.report_close_error` in a `class << self` block. Callers are not affected. Ported from rdkafka-ruby (#1068).
|
|
49
|
+
- [Maintenance] Wait 30 s for the `before(:suite)` topic creates. Ported from rdkafka-ruby (#1065).
|
|
50
|
+
- [Maintenance] Run the concurrent first produce checks on JRuby, now that `close` no longer hangs there after concurrent produces. Ported from rdkafka-ruby (#1083).
|
|
51
|
+
- [Maintenance] Create the topics of the producer `timestamp` specs with `retention.ms: -1`, so broker retention no longer deletes their messages. Ported from rdkafka-ruby (#1077).
|
|
52
|
+
- [Maintenance] Time out the SSL spec step of the Ubuntu aarch64 complementary CI workflow after 25 minutes. Ported from rdkafka-ruby (#1086).
|
|
53
|
+
- [Maintenance] Fix the YARD notes of `events_poll_nb_each` and `Consumer#poll_nb_each`: they do not hold a lock while they loop. Ported from rdkafka-ruby (#1089).
|
|
54
|
+
- [Maintenance] Stop the fake SSL servers in integration specs without `Thread#kill`. Ported from rdkafka-ruby (#1059).
|
|
55
|
+
- [Fix] Stop `Consumer#store_offset` and other calls that pass partition metadata from raising `NoMethodError` on JRuby. Ported from rdkafka-ruby (#1045).
|
|
56
|
+
- [Fix] Pass the error buffer size to librdkafka as `size_t` when setting config options and creating clients.
|
|
57
|
+
- [Fix] Raise `Rdkafka::LibraryLoadError` with the glibc upgrade hint instead of `NameError` when the precompiled librdkafka needs a newer glibc. Ported from rdkafka-ruby (#1031).
|
|
58
|
+
- [Fix] Report a failed consumer close (e.g. of a fatally-errored consumer) to `Rdkafka::Config.error_callback` instead of dropping it. `Consumer#close` still does not raise.
|
|
59
|
+
- [Fix] Stop the statistics, error and OAuth token refresh callbacks from raising `NoMethodError` when another thread clears the global callback while they run. On JRuby this aborted the process from the polling thread. Ported from rdkafka-ruby (#1058).
|
|
60
|
+
- [Fix] Stop `ShareConsumer#close` from hanging forever when it runs while the first partition assignment waits for topic metadata, by patching the bundled librdkafka (confluentinc/librdkafka#5658).
|
|
61
|
+
- [Fix] Pass the `#oauthbearer_set_token` size arguments to librdkafka as `size_t`, so the token set error is no longer truncated at random on JRuby.
|
|
62
|
+
- [Fix] Pass the fatal error buffer size (used by `Producer#fatal_error` and the error callback) and the config resource array count to librdkafka as `size_t`.
|
|
63
|
+
- [Fix] Stop the producer from retrying a message without backoff after about 25 retries, by patching the bundled librdkafka (confluentinc/librdkafka#5646).
|
|
64
|
+
- [Fix] Stop the rebalance callback from raising `LocalJumpError` when called for a client whose opaque is already gone.
|
|
65
|
+
- [Fix] Create one topic handle per topic when many threads produce to a new topic at once. On JRuby this race leaked topic handles and could crash with a segfault; `produce` now raises `TopicHandleCreationError` instead of passing a missing handle to librdkafka. Ported from rdkafka-ruby (#1056).
|
|
66
|
+
- [Fix] Count a client's (and a share consumer's) operations in progress under one lock, so on JRuby `close` no longer hangs or destroys the client while another thread still uses it. Ported from rdkafka-ruby (#1055).
|
|
67
|
+
|
|
3
68
|
## 0.31.0 (2026-10-12)
|
|
69
|
+
- **[EOL]** Drop Ruby 3.2 support; require Ruby 3.3+.
|
|
4
70
|
- [Feature] Add `Admin#describe_cluster` to get the cluster id, controller and broker nodes (with racks) without a full metadata request. Ported from rdkafka-ruby (#1015).
|
|
5
|
-
- [Feature] Add `Admin#describe_topics` to get topic ids, partition leaders
|
|
6
|
-
- [Feature] Add `Admin#describe_consumer_groups` to read
|
|
71
|
+
- [Feature] Add `Admin#describe_topics` to get topic ids, partition leaders, replicas and per-topic errors. Both methods can also return the client's authorized operations. Ported from rdkafka-ruby (#1015).
|
|
72
|
+
- [Feature] Add `Admin#describe_consumer_groups` to read consumer groups' state, type, coordinator, authorized operations and members with their current and target assignments. Ported from rdkafka-ruby (#1016).
|
|
7
73
|
- [Feature] Add `status`, `latency` and `broker_id` to `Producer::DeliveryReport`, with `#persisted?`, `#possibly_persisted?` and `#not_persisted?`, so a failed delivery tells whether a retry may duplicate the message. Ported from rdkafka-ruby (#1019).
|
|
8
74
|
- [Enhancement] Bump librdkafka to `2.16.0` for OpenSSL and libcurl security fixes. Admin requests in flight on a decommissioned broker now fail with a retryable transport error. Ported from rdkafka-ruby (#1020).
|
|
9
75
|
- [Enhancement] Bump the bundled OpenSSL to `3.5.9` (LTS) for its security fixes. Ported from rdkafka-ruby (#1007).
|
|
10
76
|
- [Enhancement] Read each pointer field once in `Message#initialize`, saving 3 allocations per consumed message. Ported from rdkafka-ruby (#1026).
|
|
11
|
-
- [Change] Drop Ruby 3.2 support; require Ruby 3.3+.
|
|
12
77
|
- [Change] Build the precompiled `aarch64-linux-musl` gem on Alpine `3.24` (was `3.23`), matching `x86_64-linux-musl`. Ported from rdkafka-ruby (#1012).
|
|
13
78
|
- [Change] Build the precompiled `macos_arm64` library on macOS 26 with the minimum macOS pinned to 14.0, instead of inheriting it from the build host. Ported from rdkafka-ruby (#1013).
|
|
14
79
|
- [Maintenance] Split `lib/rdkafka/bindings.rb` into per-area files under `lib/rdkafka/bindings/`. `Rdkafka::Bindings` is unchanged. Ported from rdkafka-ruby (#1022).
|
|
15
|
-
- [Maintenance] Stabilize
|
|
80
|
+
- [Maintenance] Stabilize a flaky partitions count cache spec. Ported from rdkafka-ruby (#1028).
|
|
16
81
|
- [Fix] Sort merged share-group async acknowledgements so the broker does not reject them with `invalid_request` (librdkafka patch).
|
|
17
|
-
- [Fix] Release share records acquired by an in-flight fetch on unsubscribe instead of keeping them locked (librdkafka patch). `ShareConsumer#unsubscribe` now closes the share sessions like `#close`
|
|
82
|
+
- [Fix] Release share records acquired by an in-flight fetch on unsubscribe instead of keeping them locked (librdkafka patch). `ShareConsumer#unsubscribe` now closes the share sessions like `#close` and can wait up to `fetch.wait.max.ms`.
|
|
18
83
|
|
|
19
84
|
## 0.30.2 (2026-10-01)
|
|
20
85
|
- [Feature] Add `ShareConsumer#events_poll` (and `#events_poll_nb`) to service the statistics, error, log and OAuthBearer callbacks without acquiring records.
|
|
@@ -23,59 +88,59 @@
|
|
|
23
88
|
- [Fix] Set `ShareConsumer#name` from the native handle at creation, so name-based callback routing (e.g. Karafka) no longer drops share-consumer statistics and errors.
|
|
24
89
|
|
|
25
90
|
## 0.30.0 (2026-09-25)
|
|
26
|
-
- [Fix] Register share consumers in `Rdkafka::Clients` and destroy the native handle when `Config#share_consumer` fails part-way, so a share consumer is no longer missed by the `at_exit` shutdown hook.
|
|
27
91
|
- [Feature] Add preview support for KIP-932 share groups ("Queues for Kafka") via `Rdkafka::ShareConsumer` (`Config#share_consumer`), with per-record acknowledgements (`:accept`, `:release`, `:reject`). Requires Apache Kafka 4.2.0+ with share groups enabled. Not production-ready.
|
|
28
|
-
- [Enhancement] `RdkafkaError.build_from_c` now uses the human-readable string librdkafka attaches to the `rd_kafka_error_t` instead of `rd_kafka_err2str`, improving diagnostics for every error-pointer path.
|
|
29
|
-
- [Enhancement] Refactor the `Helpers::OAuth` token plumbing around two private hooks so the share consumer overrides only those instead of duplicating both public methods.
|
|
30
|
-
- [Fix] Make `ShareConsumer#close` thread-safe: it now waits for in-flight operations (mirroring `NativeKafka`), preventing a double destroy when two threads race `close`.
|
|
31
|
-
- [Fix] Keep the `ShareConsumer` native handle and its GC finalizer when `close`/`destroy` report an error, so the client is no longer leaked and `close` stays retriable.
|
|
32
|
-
- [Fix] Pin the acknowledgement commit callback `FFI::Function` for the lifetime of the `ShareConsumer`, preventing a use-after-free when an unclosed consumer is garbage collected.
|
|
33
|
-
- [Fix] Make `ShareConsumer` fork-aware (mirroring `NativeKafka`): it reports `closed?` in a forked child, which no longer segfaults on `close` or finalization.
|
|
34
|
-
- [Fix] Rescue `ClosedConsumerError` in `ShareConsumer#each` only around `poll`, so a `ClosedConsumerError` raised inside the block propagates instead of silently ending iteration. Like `#poll`, `#each` can also yield an `RdkafkaError` for a record that fails to build.
|
|
35
|
-
- [Fix] Raise `ArgumentError` for `ShareConsumer#subscribe` without topics, which librdkafka otherwise treats as an unsubscribe without error, silently dropping the subscription.
|
|
36
|
-
- [Fix] Capture the librdkafka client name onto `ShareConsumer#name` from the OAuthBearer token refresh callback, since the share handle has no native name accessor for the documented name-based oauth callback routing.
|
|
37
|
-
- [Fix] Update `ext/build_common.sh` (precompiled builds) to librdkafka `2.15.0` and its tarball checksum; it still pinned `2.14.1`, whose tarball is no longer vendored.
|
|
38
|
-
- [Fix] Stop the `share_consumer_multi_member` integration spec from failing on an at-least-once redelivery; it now tracks distinct payloads and fails only when a record is never delivered.
|
|
39
|
-
- [Fix] Apply the same at-least-once tolerance to the `share_consumer_explicit_ack` integration spec: require only the released record to be redelivered, forbid the rejected one, and tolerate an accepted record reappearing.
|
|
40
|
-
- [Fix] Add the `nofile` ulimit to `docker-compose-ssl.yml` (mirroring `docker-compose.yml`) so the SSL CI broker does not exhaust file descriptors under the topic-heavy share-consumer suite.
|
|
41
|
-
- [Fix] Enable KIP-932 share groups on the macOS CI broker, whose KRaft config never opted into the share rebalance protocol, so its share-consumer spec no longer receives zero records. `CONFLUENT_VERSION` is bumped to `8.3.0`.
|
|
42
|
-
- [Enhancement] Add `share_consumer_implicit_ack` and `share_consumer_multi_topic` integration specs.
|
|
43
|
-
- [Fix] Stop the `statistics_unassigned_producer` integration spec from flaking on a metadata-propagation race by retrying the produce on `unknown_topic_or_part` and `leader_not_available`.
|
|
44
|
-
- [Fix] Also stabilize the `statistics_unassigned_producer` integration spec against a delivery wait that outlives its budget: it now uses the default 60s handle wait and retries on `WaitTimeoutError`.
|
|
45
|
-
- [Fix] Stabilize the `consumer_memberid_clusterid_leak` integration spec against RSS measurement noise on Ruby 4.0 by compacting the heap before sampling and raising the ceiling to 3 MB.
|
|
46
|
-
- [Note] Share consumers emit the regular consumer statistics through `statistics_callback`. librdkafka 2.15.0 has no share-specific metrics, so the `topics` section has no partition entries.
|
|
47
92
|
- [Feature] Add `Admin#alter_consumer_group_offsets` and `Admin#delete_consumer_group_offsets` to set or clear a consumer group's committed offsets from the admin client. Ported from rdkafka-ruby (#983).
|
|
93
|
+
- [Enhancement] Use the error string librdkafka attaches to each error in `RdkafkaError.build_from_c`, for clearer error messages.
|
|
94
|
+
- [Enhancement] Refactor the `Helpers::OAuth` token handling so the share consumer reuses it instead of duplicating it.
|
|
48
95
|
- [Enhancement] Bump librdkafka to `2.15.1` for OpenSSL and libcurl security fixes. It changes how IPv6 addresses are formatted and validated against broker certificates.
|
|
49
96
|
- [Enhancement] Bump the bundled zlib to `1.3.2`.
|
|
50
97
|
- [Enhancement] Bump the bundled MIT Kerberos (krb5) to `1.22.2`. Ported from rdkafka-ruby (#979).
|
|
51
98
|
- [Enhancement] Add `Rdkafka::Config.partitioner_key_uses_bytesize` to hash partition keys by byte length, matching other Kafka clients for multibyte keys. Defaults to `false`. Ported from rdkafka-ruby (#985).
|
|
99
|
+
- [Maintenance] Stop the `share_consumer_multi_member` integration spec from failing on an at-least-once redelivery.
|
|
100
|
+
- [Maintenance] Apply the same at-least-once tolerance to the `share_consumer_explicit_ack` integration spec.
|
|
101
|
+
- [Maintenance] Add the `nofile` ulimit to the SSL CI broker so the share-consumer suite does not exhaust file descriptors.
|
|
102
|
+
- [Maintenance] Enable KIP-932 share groups on the macOS CI broker and bump its `CONFLUENT_VERSION` to `8.3.0`.
|
|
103
|
+
- [Maintenance] Add `share_consumer_implicit_ack` and `share_consumer_multi_topic` integration specs.
|
|
104
|
+
- [Maintenance] Stop the `statistics_unassigned_producer` integration spec from flaking on a metadata-propagation race.
|
|
105
|
+
- [Maintenance] Also stabilize the `statistics_unassigned_producer` integration spec against delivery wait timeouts.
|
|
106
|
+
- [Maintenance] Stabilize the `consumer_memberid_clusterid_leak` integration spec against RSS measurement noise on Ruby 4.0.
|
|
52
107
|
- [Maintenance] Derive the zlib `CHECKSUMS` entry from `ZLIB_VERSION`.
|
|
53
108
|
- [Maintenance] Drop the unused `dist/openssl-3.0.16.tar.gz` build cache.
|
|
54
|
-
- [Fix] Honor the `isolation_level:` argument to `Admin#list_offsets`, which was silently ignored. Ported from rdkafka-ruby (#983).
|
|
55
|
-
- [Fix] Return correct results for every item of a multi-item topic, partition, group or ACL admin request, not just the first. Ported from rdkafka-ruby (#987).
|
|
56
109
|
- [Maintenance] Fix a use-after-free in the multi-item admin integration test that made it flaky on newer glibc. Ported from rdkafka-ruby (#991).
|
|
57
110
|
- [Maintenance] Stabilize consumer specs on slow CI runners. The assignment wait is tunable via `RDKAFKA_TEST_ASSIGNMENT_TIMEOUT`. Ported from rdkafka-ruby (#990).
|
|
111
|
+
- [Fix] Register share consumers in `Rdkafka::Clients` and destroy the native handle when `Config#share_consumer` fails part-way, so a share consumer is no longer missed by the `at_exit` shutdown hook.
|
|
112
|
+
- [Fix] Make `ShareConsumer#close` thread-safe: it now waits for in-flight operations (mirroring `NativeKafka`), preventing a double destroy when two threads race `close`.
|
|
113
|
+
- [Fix] Keep the `ShareConsumer` native handle and its GC finalizer when `close`/`destroy` report an error, so the client is no longer leaked and `close` stays retriable.
|
|
114
|
+
- [Fix] Prevent a use-after-free when an unclosed `ShareConsumer` is garbage collected.
|
|
115
|
+
- [Fix] Make `ShareConsumer` fork-aware (mirroring `NativeKafka`): it reports `closed?` in a forked child, which no longer segfaults on `close` or finalization.
|
|
116
|
+
- [Fix] Rescue `ClosedConsumerError` in `ShareConsumer#each` only around `poll`, so a `ClosedConsumerError` raised inside the block propagates instead of silently ending iteration. Like `#poll`, `#each` can also yield an `RdkafkaError` for a record that fails to build.
|
|
117
|
+
- [Fix] Raise `ArgumentError` for `ShareConsumer#subscribe` without topics, which librdkafka otherwise treats as an unsubscribe without error, silently dropping the subscription.
|
|
118
|
+
- [Fix] Set `ShareConsumer#name` from the OAuthBearer token refresh callback, so name-based OAuth callback routing works for share consumers.
|
|
119
|
+
- [Fix] Update `ext/build_common.sh` (precompiled builds) to librdkafka `2.15.0` and its tarball checksum; it still pinned `2.14.1`, whose tarball is no longer vendored.
|
|
120
|
+
- [Fix] Honor the `isolation_level:` argument to `Admin#list_offsets`, which was silently ignored. Ported from rdkafka-ruby (#983).
|
|
121
|
+
- [Fix] Return correct results for every item of a multi-item topic, partition, group or ACL admin request, not just the first. Ported from rdkafka-ruby (#987).
|
|
122
|
+
- [Note] Share consumers emit the regular consumer statistics through `statistics_callback`. librdkafka 2.15.0 has no share-specific metrics, so the `topics` section has no partition entries.
|
|
58
123
|
|
|
59
124
|
## 0.29.0 (2026-09-14)
|
|
60
125
|
- [Enhancement] Bump librdkafka to `2.15.0` (staying on `2.15.0` rather than `2.15.1` so users hitting a regression in `2.15.1` have a stable fallback).
|
|
61
126
|
|
|
62
|
-
## 0.28.2 (2026-09-
|
|
127
|
+
## 0.28.2 (2026-09-12)
|
|
128
|
+
- [Maintenance] Bump the bundled OpenSSL used by the precompiled builds to `3.5.8` (LTS). Ported from rdkafka-ruby (#972, Scott Francis).
|
|
63
129
|
- [Fix] Close live clients before Ruby shutdown finalization, preventing a possible segfault on exit. Ported from rdkafka-ruby (#964, Alex Selesse).
|
|
64
130
|
- [Fix] Destroy the native handle when client construction fails partway, so it is no longer orphaned. Ported from rdkafka-ruby (#964, Alex Selesse).
|
|
65
131
|
- [Fix] Fix a double-free in `Consumer#poll_batch`/`#poll_batch_nb` that could abort the process when building a message raised a non-`RdkafkaError`. Ported from rdkafka-ruby (#973).
|
|
66
132
|
- [Fix] Free native resources when `Admin#describe_configs`/`#incremental_alter_configs` raise while building their request (e.g. a non-String resource name). Ported from rdkafka-ruby (#973).
|
|
67
133
|
- [Fix] Raise `ConfigError` instead of segfaulting when `Admin#describe_configs`/`#incremental_alter_configs` get an empty resource name or a negative resource type. Ported from rdkafka-ruby (#973).
|
|
68
134
|
- [Fix] Stop the topic-partition metadata string from being freed while librdkafka still uses it. Ported from rdkafka-ruby (#969, Randy Stauner).
|
|
69
|
-
- [Maintenance] Bump the bundled OpenSSL used by the precompiled builds to `3.5.8` (LTS). Ported from rdkafka-ruby (#972, Scott Francis).
|
|
70
135
|
|
|
71
|
-
##
|
|
136
|
+
## 0.28.1 (2026-09-04)
|
|
72
137
|
- [Enhancement] Add `Admin#delete_records` to delete messages in a partition up to a given offset, or all current data with `:end`. Ported from rdkafka-ruby (#956).
|
|
73
138
|
- [Enhancement] Add `Admin#list_consumer_groups` for a cluster-wide listing of consumer groups. Ported from rdkafka-ruby (#955).
|
|
74
139
|
- [Fix] Make `NativeKafka#close` fork-aware so a forked child no longer segfaults on exit. Handles record their creator pid and skip the native teardown in any other process.
|
|
75
140
|
- [Fix] Stabilize the flaky partitions count cache statistics spec.
|
|
76
141
|
- [Fix] Stabilize the `to_native_tpl` leak integration spec against RSS measurement noise.
|
|
77
142
|
|
|
78
|
-
##
|
|
143
|
+
## 0.28.0 (2026-07-12)
|
|
79
144
|
- [Enhancement] Bump librdkafka to `2.14.2` (maintenance release with bundled dependency CVE fixes and a fix for duplicate groups in `ListConsumerGroups`).
|
|
80
145
|
- [Enhancement] Add `Consumer#metadata` and `Producer#metadata`, mirroring `Admin#metadata`, to fetch cluster metadata without a separate admin connection.
|
|
81
146
|
- [Enhancement] Name the failing topic and partition in `RdkafkaError`s raised for per-partition `list_offsets` errors.
|
|
@@ -111,10 +176,10 @@
|
|
|
111
176
|
## 0.27.2 (2026-05-21)
|
|
112
177
|
- [Enhancement] `poll_batch` and `poll_batch_nb` now return error events inline as `RdkafkaError` objects rather than raising on the first error. The return type is `Array<Message, RdkafkaError>` and callers are responsible for handling errors in the result.
|
|
113
178
|
|
|
114
|
-
## 0.27.1 (2026-05-
|
|
179
|
+
## 0.27.1 (2026-05-15)
|
|
115
180
|
- [Fix] `poll_nb`, `poll_nb_each`, `poll_batch` and `poll_batch_nb` now raise `RdkafkaError` with `details` populated (`{topic:, partition:, offset:}`) when a message contains an error, consistent with `poll`.
|
|
116
181
|
|
|
117
|
-
## 0.27.0 (2026-05-
|
|
182
|
+
## 0.27.0 (2026-05-10)
|
|
118
183
|
- [Feature] Add `Consumer#poll_batch(timeout_ms, max_items:)` and `Consumer#poll_batch_nb(timeout_ms, max_items:)` for batch message polling via `rd_kafka_consume_batch_queue` (from upstream).
|
|
119
184
|
- [Enhancement] Bump librdkafka to `2.14.1`.
|
|
120
185
|
- [Fix] Fix resource leak in `Admin#describe_configs` and `Admin#incremental_alter_configs` where `admin_options_ptr` and `queue_ptr` were not destroyed in the ensure block (from upstream).
|
|
@@ -179,7 +244,7 @@
|
|
|
179
244
|
- [Enhancement] Force lock FFI to 1.17.1 or higher to include critical bug fixes around GCC, write barriers, and thread restarts for forks.
|
|
180
245
|
- [Fix] Fix for Core dump when providing extensions to oauthbearer_set_token (dssjoblom)
|
|
181
246
|
|
|
182
|
-
## 0.22.2 (2025-10-
|
|
247
|
+
## 0.22.2 (2025-10-10)
|
|
183
248
|
- [Fix] Fix Github Action Ruby reference preventing non-compiled releases.
|
|
184
249
|
|
|
185
250
|
## 0.22.1 (2025-10-09)
|
|
@@ -201,7 +266,7 @@
|
|
|
201
266
|
- [Enhancement] Introduce an integration suite layer for non RSpec specs execution.
|
|
202
267
|
- [Fix] Add `json` gem as a dependency (was missing but used).
|
|
203
268
|
|
|
204
|
-
## 0.20.1 (2025-07-
|
|
269
|
+
## 0.20.1 (2025-07-18)
|
|
205
270
|
- [Enhancement] Drastically increase number of platforms in the integration suite
|
|
206
271
|
- [Fix] Support Ubuntu `22.04` and older Alpine precompiled versions
|
|
207
272
|
- [Fix] FFI::DynamicLibrary.load_library': Could not open library
|
data/README.md
CHANGED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
> [!NOTE]
|
|
8
8
|
> **Karafka-Rdkafka** is a fork of the [rdkafka-ruby](https://github.com/karafka/rdkafka-ruby) gem, specifically maintained for the [Karafka ecosystem](https://karafka.io). This fork exists to provide Karafka-specific patches and optimizations that are not generic enough for inclusion in the upstream rdkafka-ruby library.
|
|
9
9
|
|
|
10
|
+
> [!WARNING]
|
|
11
|
+
> **This gem is not meant to be used outside of the Karafka ecosystem.** It is a dependency of [Karafka](https://github.com/karafka/karafka), [WaterDrop](https://github.com/karafka/waterdrop) and their companion gems, not a general-purpose Kafka client. Its API follows what these gems need and can change in any release, a patch release included, without a deprecation period. Use Karafka or WaterDrop, or [rdkafka-ruby](https://github.com/karafka/rdkafka-ruby) for a standalone Kafka client.
|
|
12
|
+
|
|
10
13
|
---
|
|
11
14
|
|
|
12
15
|
## Why This Fork Exists
|
|
@@ -41,7 +44,11 @@ However, until such integration is possible, this fork ensures that Karafka user
|
|
|
41
44
|
|
|
42
45
|
### If You're Using Standalone rdkafka
|
|
43
46
|
|
|
44
|
-
You should use the [original rdkafka-ruby gem](https://github.com/karafka/rdkafka-ruby) for general Kafka client needs. This fork is specifically designed for Karafka and
|
|
47
|
+
You should use the [original rdkafka-ruby gem](https://github.com/karafka/rdkafka-ruby) for general Kafka client needs. This fork is specifically designed for Karafka and is not supported for other use cases: depending on it directly means its API can change under you in any release.
|
|
48
|
+
|
|
49
|
+
### API Stability and the Changelog
|
|
50
|
+
|
|
51
|
+
The supported users of this gem are the Karafka ecosystem gems, which are released together with it. A change to a method signature or a return value is made together with the matching change in those gems, and the changelog marks it **[Breaking]** only when it breaks a released version of one of them. Changes that only affect code calling this gem directly are listed as **[Change]**.
|
|
45
52
|
|
|
46
53
|
### Reporting Issues
|
|
47
54
|
|
|
@@ -63,11 +70,12 @@ Contributions should generally be made to the upstream [rdkafka-ruby repository]
|
|
|
63
70
|
|
|
64
71
|
| karafka-rdkafka | librdkafka | patches |
|
|
65
72
|
|-|-|-|
|
|
73
|
+
| 0.32.x (2026-11-04) | 2.16.0 (2026-10-06) | yes |
|
|
66
74
|
| 0.31.x (2026-10-12) | 2.16.0 (2026-10-06) | yes |
|
|
67
75
|
| 0.30.x (2026-09-25) | 2.15.1 (2026-09-09) | yes |
|
|
68
76
|
| 0.29.x (2026-09-14) | 2.15.0 (2026-06-30) | yes |
|
|
69
77
|
| 0.28.x (2026-07-12) | 2.14.2 (2026-06-03) | yes |
|
|
70
|
-
| 0.27.x (2026-05-
|
|
78
|
+
| 0.27.x (2026-05-10) | 2.14.1 (2026-04-15) | yes |
|
|
71
79
|
| 0.26.x (2026-04-11) | 2.14.0 (2026-04-01) | yes |
|
|
72
80
|
| 0.25.x (2026-04-02) | 2.13.2 (2026-03-02) | yes |
|
|
73
81
|
| 0.24.x (2026-02-25) | 2.13.0 (2026-01-05) | yes |
|
|
@@ -78,10 +86,10 @@ Contributions should generally be made to the upstream [rdkafka-ruby repository]
|
|
|
78
86
|
| 0.19.x (2025-01-20) | 2.8.0 (2025-01-07) | yes |
|
|
79
87
|
| 0.18.0 (2024-11-26) | 2.6.1 (2024-11-18) | yes |
|
|
80
88
|
| 0.17.4 (2024-09-02) | 2.5.3 (2024-09-02) | yes |
|
|
81
|
-
| 0.17.0 (2024-
|
|
82
|
-
| 0.16.0 (2024-06-
|
|
83
|
-
| 0.15.0 (
|
|
84
|
-
| 0.14.0 (2023-11-
|
|
89
|
+
| 0.17.0 (2024-07-21) | 2.5.0 (2024-07-10) | yes |
|
|
90
|
+
| 0.16.0 (2024-06-17) | 2.4.0 (2024-05-07) | no |
|
|
91
|
+
| 0.15.0 (2024-04-26) | 2.3.0 (2023-10-25) | no |
|
|
92
|
+
| 0.14.0 (2023-11-17) | 2.2.0 (2023-07-12) | no |
|
|
85
93
|
| 0.13.0 (2023-07-24) | 2.0.2 (2023-01-20) | no |
|
|
86
94
|
| 0.12.0 (2022-06-17) | 1.9.0 (2022-06-16) | no |
|
|
87
95
|
| 0.11.0 (2021-11-17) | 1.8.2 (2021-10-18) | no |
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# This patch is released under the 2-clause BSD license, same as librdkafka
|
|
2
|
+
#
|
|
3
|
+
# Upstream: https://github.com/confluentinc/librdkafka/issues/5658
|
|
4
|
+
# Drop this patch once librdkafka drops a target assignment whose metadata arrives
|
|
5
|
+
# after the consumer left the group.
|
|
6
|
+
#
|
|
7
|
+
--- librdkafka_2.16.0/src/rdkafka_cgrp.c
|
|
8
|
+
+++ librdkafka_2.16.0/src/rdkafka_cgrp.c
|
|
9
|
+
@@ -3083,6 +3083,24 @@ rd_kafka_cgrp_consumer_handle_Metadata_op(rd_kafka_t *rk,
|
|
10
|
+
if (!rkcg->rkcg_next_target_assignment)
|
|
11
|
+
return RD_KAFKA_OP_RES_HANDLED;
|
|
12
|
+
|
|
13
|
+
+ if (!(rkcg->rkcg_flags & RD_KAFKA_CGRP_F_SUBSCRIPTION) ||
|
|
14
|
+
+ (rkcg->rkcg_flags & RD_KAFKA_CGRP_F_TERMINATE)) {
|
|
15
|
+
+ /* Consumer left the group (unsubscribe or close) while the
|
|
16
|
+
+ * metadata request was in-flight: drop the target assignment,
|
|
17
|
+
+ * like the heartbeat response handlers do. Assigning it now
|
|
18
|
+
+ * adds partitions that no later heartbeat revokes, so a close
|
|
19
|
+
+ * waits for them forever. */
|
|
20
|
+
+ rd_kafka_dbg(rkcg->rkcg_rk, CGRP, "HEARTBEAT",
|
|
21
|
+
+ "Group \"%s\": dropping next target assignment: "
|
|
22
|
+
+ "consumer left the group while its metadata "
|
|
23
|
+
+ "request was in-flight",
|
|
24
|
+
+ rkcg->rkcg_group_id->str);
|
|
25
|
+
+ rd_kafka_topic_partition_list_destroy(
|
|
26
|
+
+ rkcg->rkcg_next_target_assignment);
|
|
27
|
+
+ rkcg->rkcg_next_target_assignment = NULL;
|
|
28
|
+
+ return RD_KAFKA_OP_RES_HANDLED;
|
|
29
|
+
+ }
|
|
30
|
+
+
|
|
31
|
+
assignment_with_metadata =
|
|
32
|
+
rd_kafka_cgrp_consumer_assignment_with_metadata(
|
|
33
|
+
rkcg, rkcg->rkcg_next_target_assignment, NULL);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# This patch is released under the 2-clause BSD license, same as librdkafka
|
|
2
|
+
#
|
|
3
|
+
# Upstream: https://github.com/confluentinc/librdkafka/pull/5611
|
|
4
|
+
# Drop this patch once the bundled librdkafka includes that fix.
|
|
5
|
+
#
|
|
6
|
+
--- librdkafka_2.16.0/src/rdkafka_request.c
|
|
7
|
+
+++ librdkafka_2.16.0/src/rdkafka_request.c
|
|
8
|
+
@@ -1372,9 +1372,10 @@
|
|
9
|
+
|
|
10
|
+
actions = rd_kafka_handle_OffsetFetch_err_action(rkb, err, request);
|
|
11
|
+
|
|
12
|
+
- if (actions & RD_KAFKA_ERR_ACTION_REFRESH) {
|
|
13
|
+
- /* Re-query for coordinator */
|
|
14
|
+
- rd_kafka_cgrp_op(rkb->rkb_rk->rk_cgrp, NULL, RD_KAFKA_NO_REPLYQ,
|
|
15
|
+
+ if ((actions & RD_KAFKA_ERR_ACTION_REFRESH) && rk->rk_cgrp) {
|
|
16
|
+
+ /* Re-query for coordinator only if this client has a consumer
|
|
17
|
+
+ * group. Admin requests may use clients without one. */
|
|
18
|
+
+ rd_kafka_cgrp_op(rk->rk_cgrp, NULL, RD_KAFKA_NO_REPLYQ,
|
|
19
|
+
RD_KAFKA_OP_COORD_QUERY, err);
|
|
20
|
+
}
|
|
21
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# This patch is released under the 2-clause BSD license, same as librdkafka
|
|
2
|
+
#
|
|
3
|
+
# Upstream: https://github.com/confluentinc/librdkafka/issues/5646
|
|
4
|
+
# Drop this patch once librdkafka caps the message retry backoff shift itself.
|
|
5
|
+
#
|
|
6
|
+
--- librdkafka_2.16.0/src/rdkafka_partition.c
|
|
7
|
+
+++ librdkafka_2.16.0/src/rdkafka_partition.c
|
|
8
|
+
@@ -1000,11 +1000,17 @@
|
|
9
|
+
/* In some cases, like failed Produce requests do not
|
|
10
|
+
* increment the retry count, see
|
|
11
|
+
* rd_kafka_handle_Produce_error. */
|
|
12
|
+
- if (rkm->rkm_u.producer.retries > 0)
|
|
13
|
+
- backoff =
|
|
14
|
+
- (1 << (rkm->rkm_u.producer.retries - 1)) *
|
|
15
|
+
- retry_ms;
|
|
16
|
+
- else
|
|
17
|
+
+ if (rkm->rkm_u.producer.retries > 0) {
|
|
18
|
+
+ int shift = rkm->rkm_u.producer.retries - 1;
|
|
19
|
+
+
|
|
20
|
+
+ /* Cap shift at 34 to prevent overflow in final
|
|
21
|
+
+ * calculation, as in
|
|
22
|
+
+ * rd_kafka_broker_buf_retry(). */
|
|
23
|
+
+ if (shift > 34)
|
|
24
|
+
+ shift = 34;
|
|
25
|
+
+
|
|
26
|
+
+ backoff = ((int64_t)1 << shift) * retry_ms;
|
|
27
|
+
+ } else
|
|
28
|
+
backoff = retry_ms;
|
|
29
|
+
/* Multiplied by 10 as backoff should be in nano
|
|
30
|
+
* seconds. */
|
data/karafka-rdkafka.gemspec
CHANGED
|
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
|
6
6
|
gem.authors = ["Thijs Cadier", "Maciej Mensfeld"]
|
|
7
7
|
gem.email = ["contact@karafka.io"]
|
|
8
8
|
gem.description = "Modern Kafka client library for Ruby based on librdkafka"
|
|
9
|
-
gem.summary = "The rdkafka gem is a modern Kafka client library for Ruby based on librdkafka. It wraps the production-ready C client using the ffi gem and targets Kafka 1.0+ and Ruby
|
|
9
|
+
gem.summary = "The rdkafka gem is a modern Kafka client library for Ruby based on librdkafka. It wraps the production-ready C client using the ffi gem and targets Kafka 1.0+ and Ruby 3.3+."
|
|
10
10
|
gem.license = "MIT"
|
|
11
11
|
|
|
12
12
|
gem.name = "karafka-rdkafka"
|
|
@@ -65,13 +65,14 @@ Gem::Specification.new do |gem|
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
gem.extensions = %w[ext/Rakefile]
|
|
68
|
+
|
|
69
|
+
gem.add_dependency "mini_portile2", "~> 2.6"
|
|
70
|
+
gem.add_dependency "rake", "> 12"
|
|
68
71
|
end
|
|
69
72
|
|
|
70
73
|
gem.add_dependency "ffi", "~> 1.17.1"
|
|
71
74
|
gem.add_dependency "json", "> 2.0"
|
|
72
75
|
gem.add_dependency "logger"
|
|
73
|
-
gem.add_dependency "mini_portile2", "~> 2.6"
|
|
74
|
-
gem.add_dependency "rake", "> 12"
|
|
75
76
|
|
|
76
77
|
gem.metadata = {
|
|
77
78
|
"funding_uri" => "https://karafka.io/#become-pro",
|
|
@@ -22,9 +22,20 @@ module Rdkafka
|
|
|
22
22
|
REGISTRY_MUTEX = Mutex.new
|
|
23
23
|
# Default wait timeout is 31 years
|
|
24
24
|
MAX_WAIT_TIMEOUT_FOREVER = 10_000_000_000
|
|
25
|
+
# Number of shared lock stripes (power of two)
|
|
26
|
+
LOCK_STRIPES_COUNT = 1_024
|
|
27
|
+
# Shared `[Mutex, ConditionVariable]` pairs for `#wait` and `#unlock`, so a handle does not
|
|
28
|
+
# allocate its own. A handle picks its stripe by native address, which is stable for its life.
|
|
29
|
+
# A broadcast for another handle on the same stripe is a spurious wakeup: `#wait` re-checks
|
|
30
|
+
# `pending?` after every wakeup.
|
|
31
|
+
LOCK_STRIPES = Array.new(LOCK_STRIPES_COUNT) do
|
|
32
|
+
[Thread::Mutex.new, Thread::ConditionVariable.new].freeze
|
|
33
|
+
end.freeze
|
|
25
34
|
|
|
26
35
|
private_constant :REGISTRY_MUTEX
|
|
27
36
|
private_constant :MAX_WAIT_TIMEOUT_FOREVER
|
|
37
|
+
private_constant :LOCK_STRIPES_COUNT
|
|
38
|
+
private_constant :LOCK_STRIPES
|
|
28
39
|
|
|
29
40
|
class << self
|
|
30
41
|
# Adds handle to the register
|
|
@@ -54,13 +65,6 @@ module Rdkafka
|
|
|
54
65
|
# callback, used by `#raise_error`
|
|
55
66
|
attr_accessor :broker_message
|
|
56
67
|
|
|
57
|
-
def initialize
|
|
58
|
-
@mutex = Thread::Mutex.new
|
|
59
|
-
@resource = Thread::ConditionVariable.new
|
|
60
|
-
|
|
61
|
-
super
|
|
62
|
-
end
|
|
63
|
-
|
|
64
68
|
# Whether the handle is still pending.
|
|
65
69
|
#
|
|
66
70
|
# @return [Boolean]
|
|
@@ -101,13 +105,15 @@ module Rdkafka
|
|
|
101
105
|
timeout_s = timeout_ms ? timeout_ms / 1000.0 : nil
|
|
102
106
|
timeout = timeout_s ? monotonic_now + timeout_s : MAX_WAIT_TIMEOUT_FOREVER
|
|
103
107
|
|
|
104
|
-
|
|
108
|
+
mutex, resource = lock_stripe
|
|
109
|
+
|
|
110
|
+
mutex.synchronize do
|
|
105
111
|
loop do
|
|
106
112
|
if pending?
|
|
107
113
|
to_wait = (timeout - monotonic_now)
|
|
108
114
|
|
|
109
115
|
if to_wait.positive?
|
|
110
|
-
|
|
116
|
+
resource.wait(mutex, to_wait)
|
|
111
117
|
else
|
|
112
118
|
raise WaitTimeoutError.new(
|
|
113
119
|
"Waiting for #{operation_name} timed out after #{timeout_ms} ms"
|
|
@@ -124,9 +130,11 @@ module Rdkafka
|
|
|
124
130
|
|
|
125
131
|
# Unlock the resources
|
|
126
132
|
def unlock
|
|
127
|
-
|
|
133
|
+
mutex, resource = lock_stripe
|
|
134
|
+
|
|
135
|
+
mutex.synchronize do
|
|
128
136
|
self[:pending] = false
|
|
129
|
-
|
|
137
|
+
resource.broadcast
|
|
130
138
|
end
|
|
131
139
|
end
|
|
132
140
|
|
|
@@ -163,5 +171,12 @@ module Rdkafka
|
|
|
163
171
|
# Error that is raised when waiting for the handle to complete
|
|
164
172
|
# takes longer than the specified timeout.
|
|
165
173
|
class WaitTimeoutError < RuntimeError; end
|
|
174
|
+
|
|
175
|
+
private
|
|
176
|
+
|
|
177
|
+
# @return [Array(Thread::Mutex, Thread::ConditionVariable)] lock stripe of this handle
|
|
178
|
+
def lock_stripe
|
|
179
|
+
LOCK_STRIPES[(to_ptr.address >> 4) & (LOCK_STRIPES_COUNT - 1)]
|
|
180
|
+
end
|
|
166
181
|
end
|
|
167
182
|
end
|
|
@@ -18,30 +18,18 @@ module Rdkafka
|
|
|
18
18
|
rd_kafka_error_pointer = Rdkafka::Bindings.rd_kafka_AclBinding_error(matching_acl)
|
|
19
19
|
@result_error = Rdkafka::Bindings.rd_kafka_error_code(rd_kafka_error_pointer)
|
|
20
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
|
|
24
|
-
end
|
|
21
|
+
@error_string = error_string.null? ? nil : error_string.read_string
|
|
25
22
|
|
|
26
23
|
@matching_acl_resource_type = Rdkafka::Bindings.rd_kafka_AclBinding_restype(matching_acl)
|
|
27
24
|
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
|
|
25
|
+
@matching_acl_resource_name = matching_acl_resource_name.null? ? nil : matching_acl_resource_name.read_string
|
|
32
26
|
|
|
33
27
|
@matching_acl_resource_pattern_type = Rdkafka::Bindings.rd_kafka_AclBinding_resource_pattern_type(matching_acl)
|
|
34
28
|
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
|
|
29
|
+
@matching_acl_principal = matching_acl_principal.null? ? nil : matching_acl_principal.read_string
|
|
39
30
|
|
|
40
31
|
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
|
|
32
|
+
@matching_acl_host = matching_acl_host.null? ? nil : matching_acl_host.read_string
|
|
45
33
|
|
|
46
34
|
@matching_acl_operation = Rdkafka::Bindings.rd_kafka_AclBinding_operation(matching_acl)
|
|
47
35
|
@matching_acl_permission_type = Rdkafka::Bindings.rd_kafka_AclBinding_permission_type(matching_acl)
|
|
@@ -20,8 +20,8 @@ module Rdkafka
|
|
|
20
20
|
# @param result_name [FFI::Pointer] pointer to the group name
|
|
21
21
|
# @param partitions_ptr [FFI::Pointer] pointer to the per partition result list
|
|
22
22
|
def initialize(error_string, result_name, partitions_ptr = FFI::Pointer::NULL)
|
|
23
|
-
@error_string = error_string.
|
|
24
|
-
@group_name = result_name.
|
|
23
|
+
@error_string = error_string.null? ? nil : error_string.read_string
|
|
24
|
+
@group_name = result_name.null? ? nil : result_name.read_string
|
|
25
25
|
@partitions = extract_partitions(partitions_ptr)
|
|
26
26
|
end
|
|
27
27
|
|
|
@@ -6,6 +6,12 @@ module Rdkafka
|
|
|
6
6
|
class ConfigBindingResult
|
|
7
7
|
attr_reader :name, :value, :read_only, :default, :sensitive, :synonym, :synonyms
|
|
8
8
|
|
|
9
|
+
# @return [Integer] where the value comes from, one of `Bindings::RD_KAFKA_CONFIG_SOURCE_*`
|
|
10
|
+
attr_reader :source
|
|
11
|
+
|
|
12
|
+
# @return [String] name of the source, e.g. `"DYNAMIC_TOPIC_CONFIG"`
|
|
13
|
+
attr_reader :source_name
|
|
14
|
+
|
|
9
15
|
# @param config_ptr [FFI::Pointer] config pointer
|
|
10
16
|
def initialize(config_ptr)
|
|
11
17
|
@name = Bindings.rd_kafka_ConfigEntry_name(config_ptr)
|
|
@@ -14,6 +20,8 @@ module Rdkafka
|
|
|
14
20
|
@default = Bindings.rd_kafka_ConfigEntry_is_default(config_ptr)
|
|
15
21
|
@sensitive = Bindings.rd_kafka_ConfigEntry_is_sensitive(config_ptr)
|
|
16
22
|
@synonym = Bindings.rd_kafka_ConfigEntry_is_synonym(config_ptr)
|
|
23
|
+
@source = Bindings.rd_kafka_ConfigEntry_source(config_ptr)
|
|
24
|
+
@source_name = Bindings.rd_kafka_ConfigSource_name(@source)
|
|
17
25
|
@synonyms = []
|
|
18
26
|
|
|
19
27
|
# The code below builds up the config synonyms using same config binding
|
|
@@ -17,9 +17,7 @@ module Rdkafka
|
|
|
17
17
|
# @param rdkafka_response_string [FFI::Pointer] pointer to response string
|
|
18
18
|
def initialize(rdkafka_response:, rdkafka_response_string:)
|
|
19
19
|
@rdkafka_response = rdkafka_response
|
|
20
|
-
|
|
21
|
-
@rdkafka_response_string = rdkafka_response_string.read_string
|
|
22
|
-
end
|
|
20
|
+
@rdkafka_response_string = rdkafka_response_string.null? ? nil : rdkafka_response_string.read_string
|
|
23
21
|
end
|
|
24
22
|
end
|
|
25
23
|
end
|
|
@@ -15,12 +15,8 @@ module Rdkafka
|
|
|
15
15
|
# @param error_string [FFI::Pointer] pointer to error string
|
|
16
16
|
# @param result_name [FFI::Pointer] pointer to topic name
|
|
17
17
|
def initialize(error_string, result_name)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
if result_name != FFI::Pointer::NULL
|
|
22
|
-
@result_name = result_name.read_string
|
|
23
|
-
end
|
|
18
|
+
@error_string = error_string.null? ? nil : error_string.read_string
|
|
19
|
+
@result_name = result_name.null? ? nil : result_name.read_string
|
|
24
20
|
end
|
|
25
21
|
end
|
|
26
22
|
end
|
|
@@ -20,8 +20,8 @@ module Rdkafka
|
|
|
20
20
|
# @param result_name [FFI::Pointer] pointer to the group name
|
|
21
21
|
# @param partitions_ptr [FFI::Pointer] pointer to the per partition result list
|
|
22
22
|
def initialize(error_string, result_name, partitions_ptr = FFI::Pointer::NULL)
|
|
23
|
-
@error_string = error_string.
|
|
24
|
-
@group_name = result_name.
|
|
23
|
+
@error_string = error_string.null? ? nil : error_string.read_string
|
|
24
|
+
@group_name = result_name.null? ? nil : result_name.read_string
|
|
25
25
|
@partitions = extract_partitions(partitions_ptr)
|
|
26
26
|
end
|
|
27
27
|
|
|
@@ -15,12 +15,8 @@ module Rdkafka
|
|
|
15
15
|
# @param error_string [FFI::Pointer] pointer to error string
|
|
16
16
|
# @param result_name [FFI::Pointer] pointer to group name
|
|
17
17
|
def initialize(error_string, result_name)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
if result_name != FFI::Pointer::NULL
|
|
22
|
-
@result_name = result_name.read_string
|
|
23
|
-
end
|
|
18
|
+
@error_string = error_string.null? ? nil : error_string.read_string
|
|
19
|
+
@result_name = result_name.null? ? nil : result_name.read_string
|
|
24
20
|
end
|
|
25
21
|
end
|
|
26
22
|
end
|
|
@@ -15,12 +15,8 @@ module Rdkafka
|
|
|
15
15
|
# @param error_string [FFI::Pointer] pointer to error string
|
|
16
16
|
# @param result_name [FFI::Pointer] pointer to topic name
|
|
17
17
|
def initialize(error_string, result_name)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
if result_name != FFI::Pointer::NULL
|
|
22
|
-
@result_name = result_name.read_string
|
|
23
|
-
end
|
|
18
|
+
@error_string = error_string.null? ? nil : error_string.read_string
|
|
19
|
+
@result_name = result_name.null? ? nil : result_name.read_string
|
|
24
20
|
end
|
|
25
21
|
end
|
|
26
22
|
end
|