rdkafka 0.22.2 → 0.29.0
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 +101 -3
- data/README.md +21 -14
- data/Rakefile +21 -21
- data/bin/verify_kafka_warnings +39 -0
- data/dist/{librdkafka-2.8.0.tar.gz → librdkafka-2.14.2.tar.gz} +0 -0
- data/docker-compose-ssl.yml +35 -0
- data/docker-compose.yml +2 -2
- data/ext/Rakefile +27 -27
- data/lib/rdkafka/abstract_handle.rb +54 -7
- data/lib/rdkafka/admin/acl_binding_result.rb +5 -5
- data/lib/rdkafka/admin/config_binding_result.rb +2 -2
- data/lib/rdkafka/admin/config_resource_binding_result.rb +1 -0
- data/lib/rdkafka/admin/create_acl_handle.rb +10 -6
- data/lib/rdkafka/admin/create_acl_report.rb +3 -2
- data/lib/rdkafka/admin/create_partitions_handle.rb +8 -7
- data/lib/rdkafka/admin/create_partitions_report.rb +1 -0
- data/lib/rdkafka/admin/create_topic_handle.rb +8 -7
- data/lib/rdkafka/admin/create_topic_report.rb +3 -0
- data/lib/rdkafka/admin/delete_acl_handle.rb +9 -8
- data/lib/rdkafka/admin/delete_acl_report.rb +5 -3
- data/lib/rdkafka/admin/delete_groups_handle.rb +10 -7
- data/lib/rdkafka/admin/delete_groups_report.rb +3 -0
- data/lib/rdkafka/admin/delete_topic_handle.rb +8 -7
- data/lib/rdkafka/admin/delete_topic_report.rb +3 -0
- data/lib/rdkafka/admin/describe_acl_handle.rb +9 -8
- data/lib/rdkafka/admin/describe_acl_report.rb +5 -3
- data/lib/rdkafka/admin/describe_configs_handle.rb +7 -10
- data/lib/rdkafka/admin/describe_configs_report.rb +8 -6
- data/lib/rdkafka/admin/incremental_alter_configs_handle.rb +7 -10
- data/lib/rdkafka/admin/incremental_alter_configs_report.rb +8 -6
- data/lib/rdkafka/admin/list_offsets_handle.rb +31 -0
- data/lib/rdkafka/admin/list_offsets_report.rb +51 -0
- data/lib/rdkafka/admin.rb +357 -159
- data/lib/rdkafka/bindings.rb +205 -111
- data/lib/rdkafka/callbacks/base_handler.rb +62 -0
- data/lib/rdkafka/callbacks/create_acl_handler.rb +37 -0
- data/lib/rdkafka/callbacks/create_partitions_handler.rb +37 -0
- data/lib/rdkafka/callbacks/create_topic_handler.rb +37 -0
- data/lib/rdkafka/callbacks/delete_acl_handler.rb +42 -0
- data/lib/rdkafka/callbacks/delete_groups_handler.rb +37 -0
- data/lib/rdkafka/callbacks/delete_topic_handler.rb +37 -0
- data/lib/rdkafka/callbacks/describe_acl_handler.rb +35 -0
- data/lib/rdkafka/callbacks/describe_configs_handler.rb +42 -0
- data/lib/rdkafka/callbacks/incremental_alter_configs_handler.rb +42 -0
- data/lib/rdkafka/callbacks/list_offsets_handler.rb +42 -0
- data/lib/rdkafka/callbacks.rb +125 -216
- data/lib/rdkafka/config.rb +126 -66
- data/lib/rdkafka/consumer/headers.rb +22 -7
- data/lib/rdkafka/consumer/message.rb +12 -11
- data/lib/rdkafka/consumer/partition.rb +15 -4
- data/lib/rdkafka/consumer/topic_partition_list.rb +64 -38
- data/lib/rdkafka/consumer.rb +513 -59
- data/lib/rdkafka/defaults.rb +125 -0
- data/lib/rdkafka/error.rb +40 -14
- data/lib/rdkafka/helpers/metadata.rb +29 -0
- data/lib/rdkafka/helpers/oauth.rb +45 -13
- data/lib/rdkafka/helpers/time.rb +5 -0
- data/lib/rdkafka/metadata.rb +128 -37
- data/lib/rdkafka/native_kafka.rb +91 -8
- data/lib/rdkafka/producer/delivery_handle.rb +6 -6
- data/lib/rdkafka/producer/delivery_report.rb +10 -6
- data/lib/rdkafka/producer/partitions_count_cache.rb +51 -55
- data/lib/rdkafka/producer.rb +193 -95
- data/lib/rdkafka/version.rb +6 -3
- data/lib/rdkafka.rb +15 -0
- data/package-lock.json +331 -0
- data/package.json +9 -0
- data/rdkafka.gemspec +58 -36
- data/renovate.json +39 -23
- metadata +39 -125
- data/.github/CODEOWNERS +0 -3
- data/.github/FUNDING.yml +0 -1
- data/.github/workflows/ci_linux_x86_64_gnu.yml +0 -271
- data/.github/workflows/ci_linux_x86_64_musl.yml +0 -194
- data/.github/workflows/ci_macos_arm64.yml +0 -284
- data/.github/workflows/push_linux_x86_64_gnu.yml +0 -65
- data/.github/workflows/push_linux_x86_64_musl.yml +0 -79
- data/.github/workflows/push_macos_arm64.yml +0 -54
- data/.github/workflows/push_ruby.yml +0 -37
- data/.github/workflows/verify-action-pins.yml +0 -16
- data/.gitignore +0 -14
- data/.rspec +0 -2
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.yardopts +0 -2
- data/Gemfile +0 -5
- data/ext/README.md +0 -19
- data/ext/build_common.sh +0 -361
- data/ext/build_linux_x86_64_gnu.sh +0 -306
- data/ext/build_linux_x86_64_musl.sh +0 -763
- data/ext/build_macos_arm64.sh +0 -550
- data/spec/rdkafka/abstract_handle_spec.rb +0 -117
- data/spec/rdkafka/admin/create_acl_handle_spec.rb +0 -56
- data/spec/rdkafka/admin/create_acl_report_spec.rb +0 -18
- data/spec/rdkafka/admin/create_topic_handle_spec.rb +0 -52
- data/spec/rdkafka/admin/create_topic_report_spec.rb +0 -16
- data/spec/rdkafka/admin/delete_acl_handle_spec.rb +0 -85
- data/spec/rdkafka/admin/delete_acl_report_spec.rb +0 -72
- data/spec/rdkafka/admin/delete_topic_handle_spec.rb +0 -52
- data/spec/rdkafka/admin/delete_topic_report_spec.rb +0 -16
- data/spec/rdkafka/admin/describe_acl_handle_spec.rb +0 -85
- data/spec/rdkafka/admin/describe_acl_report_spec.rb +0 -73
- data/spec/rdkafka/admin_spec.rb +0 -971
- data/spec/rdkafka/bindings_spec.rb +0 -199
- data/spec/rdkafka/callbacks_spec.rb +0 -20
- data/spec/rdkafka/config_spec.rb +0 -258
- data/spec/rdkafka/consumer/headers_spec.rb +0 -73
- data/spec/rdkafka/consumer/message_spec.rb +0 -139
- data/spec/rdkafka/consumer/partition_spec.rb +0 -57
- data/spec/rdkafka/consumer/topic_partition_list_spec.rb +0 -248
- data/spec/rdkafka/consumer_spec.rb +0 -1274
- data/spec/rdkafka/error_spec.rb +0 -89
- data/spec/rdkafka/metadata_spec.rb +0 -79
- data/spec/rdkafka/native_kafka_spec.rb +0 -130
- data/spec/rdkafka/producer/delivery_handle_spec.rb +0 -45
- data/spec/rdkafka/producer/delivery_report_spec.rb +0 -25
- data/spec/rdkafka/producer/partitions_count_cache_spec.rb +0 -359
- data/spec/rdkafka/producer_spec.rb +0 -1345
- data/spec/spec_helper.rb +0 -195
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ca57ade30bf93bb0e222709e64ff09c365ea29bf93b8f040d59157a39ed9ca79
|
|
4
|
+
data.tar.gz: 0c255e20b62b018075182ae474237765fa2e8d78f88047ac19ff92c239373fc7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48ee067dc2d35d877601198b436450fce3ff8884ca10d129d00af822e2cf823310d6636be55f48bb82658a42b8221437a6b7025a5c402719cabd091f48d1b092
|
|
7
|
+
data.tar.gz: ed3695c92af1b5b8d08a38e797fceca8ec5e081ab0b88741f788f40b945df4707d58579f93aa6acbe70d3cb9002653bb65d4f5daa6d960f310ca5df91ab85fc2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,107 @@
|
|
|
1
1
|
# Rdkafka Changelog
|
|
2
2
|
|
|
3
|
+
## 0.29.0 (2026-07-10)
|
|
4
|
+
- [Enhancement] Bump librdkafka to `2.14.2`
|
|
5
|
+
- [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
|
+
- [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
|
+
- [Fix] Cache the partition count for a missing topic. `Producer#partition_count` rescued `unknown_topic_or_part` outside the cache block, so nothing was cached and every `produce(partition_key:)` to a missing topic re-ran a blocking metadata query. The rescue now runs inside the cache block so `RD_KAFKA_PARTITION_UA` is cached like any other count; other errors are still re-raised.
|
|
8
|
+
- [Fix] Let `PartitionsCountCache` adopt a lower partition count once the cached entry has expired. The cache prioritizes higher counts (partition counts only grow during normal operation), but it did so unconditionally: after the TTL expired it fetched the true lower count, discarded it, and re-armed the TTL on the stale higher count - permanently. A topic recreated with fewer partitions then made `produce` (with a partition key) fail with `unknown_partition` for the dropped partitions until process restart. A lower value is now adopted on the first refresh after expiry, while still being ignored within the TTL window so a transient or racy lower read cannot clobber a correct higher count.
|
|
9
|
+
- [Fix] Surface per-message build errors inline in `Consumer#poll_batch`/`#poll_batch_nb` instead of discarding the batch. A message that failed to build (e.g. a header read error) raised out of the loop, losing the already-built messages - whose offsets may have been auto-stored - while error-flagged messages were already returned inline. Build failures are now returned as inline `RdkafkaError` entries alongside the successfully built messages.
|
|
10
|
+
- [Fix] Bound the `Metadata` retry loop by a wall-clock budget (`Defaults::METADATA_RETRY_BUDGET_MS`, 5s) with a minimum-attempts floor (`Defaults::METADATA_MIN_ATTEMPTS`, 3), cap the exponential backoff at `Defaults::METADATA_RETRY_BACKOFF_MAX_MS` (1s), and stop overwriting the request timeout with the backoff value. Each retry used to shrink the first retries' request timeout below the configured value (near-guaranteeing another timeout) and inflate later ones to ~100s, with cumulative sleeps alone reaching ~204s - a synchronous metadata fetch could block the caller for minutes.
|
|
11
|
+
- [Fix] Synchronize `AbstractHandle::REGISTRY` mutations. The handle registry is a plain Hash mutated from producing/consuming threads and the background polling thread (which removes handles from FFI callbacks). That is effectively safe on MRI under the GVL but not on JRuby, where a lost write could leave a handle unregistered (never unlocked, so `wait` times out for a delivered message) or never removed (permanent leak). `register`/`remove` now guard the Hash with a mutex.
|
|
12
|
+
- [Fix] Fix the NULL background-queue cleanup branches in `Admin#delete_group`, `Admin#delete_acl` and `Admin#describe_acl`, which referenced undefined local variables. When `rd_kafka_queue_get_background` returned NULL, those branches raised a `NameError` instead of the intended `ConfigError` and leaked the already-allocated native request object, and `delete_group` additionally called the wrong destructor. They now destroy the correct object and raise `ConfigError`.
|
|
13
|
+
- [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. The conf is built with `rd_kafka_topic_conf_new` and only handed to `rd_kafka_topic_new` afterwards; if `rd_kafka_topic_conf_set` returned a non-`:config_ok` result the method raised before `rd_kafka_topic_new` was ever called, so librdkafka never took ownership of the conf and it leaked. The conf is now destroyed before raising.
|
|
15
|
+
- [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
|
+
- [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. The finalizer used the generic `NativeKafka` one, which went straight to `rd_kafka_destroy` and skipped `rd_kafka_consumer_close` and `rd_kafka_queue_destroy`. A consumer that used `poll_batch` (which takes a consumer-queue reference) and was then garbage-collected without an explicit `close` left that reference dangling, which could make `rd_kafka_destroy` block inside the finalizer (process hang at GC/shutdown) or leak the handle. The consumer now installs its own finalizer that mirrors `#close` (the queue pointer is shared with the finalizer via a holder so it never captures the consumer and prevents collection).
|
|
18
|
+
- [Fix] Free the librdkafka-allocated string in `Consumer#cluster_id` and `Consumer#member_id` (previously copied via a `:string` binding but never freed) and fix the `rd_kafka_clusterid` arity to pass `timeout_ms`. `Consumer#cluster_id` now accepts a `timeout_ms` (default `Defaults::CONSUMER_CLUSTER_ID_TIMEOUT_MS`).
|
|
19
|
+
- [Fix] Attach `rd_kafka_query_watermark_offsets` with `blocking: true` so it releases the GVL during its broker round-trip. It was the only synchronous network call bound without the flag, so `Consumer#query_watermark_offsets` (and `Consumer#lag`, which calls it once per partition) froze every other Ruby thread in the process - including producer polling threads - for up to `timeout_ms`. Matches the neighboring `rd_kafka_offsets_for_times` binding.
|
|
20
|
+
- [Fix] Stop leaking the native `rd_kafka_conf_t` when client creation fails. `native_config` raised `ConfigError` mid-build (e.g. on an invalid option) without destroying the conf, and `native_kafka` raised `ClientCreationError` on a null `rd_kafka_new` without destroying it either. Both paths now call `rd_kafka_conf_destroy` before re-raising (librdkafka keeps app ownership of the conf on `rd_kafka_new` failure, so this is safe). Multi-KB leak per failed creation, relevant for supervisors retrying client creation on transient SASL/SSL misconfig.
|
|
21
|
+
- [Fix] Stop `Metadata` from leaking the native metadata struct (and a topic reference) on every retried fetch. `retry` restarts the `begin` block without running its `ensure`, so each retried attempt reassigned the pointers and only the last attempt's `rd_kafka_metadata` struct was ever destroyed; up to `METADATA_MAX_RETRIES` whole-cluster structs leaked per call (the `leader_not_available` case is routine during topic creation/leader election). Each attempt now frees its own native resources, and a failed fetch that never allocated a struct no longer calls `rd_kafka_metadata_destroy` on a NULL pointer.
|
|
22
|
+
- [Fix] Stop `Producer#produce` from orphaning the delivery handle in the process-global registry when it fails after registering it. The handle was only removed on a non-zero `rd_kafka_producev` return, so any exception between registration and that check (a concurrent `close` making `with_inner` raise `ClosedInnerError`, or a header value whose `#to_s` raises) leaked the handle forever - it survives producer close and accumulates in apps that recreate/close producers. `produce` now removes the handle on any such failure before re-raising.
|
|
23
|
+
- [Fix] Guard the message delivery callback so a raising user `delivery_callback` can no longer skip the handle unlock or crash the producer. `DeliveryCallback` invoked the user callback and only then unlocked the handle, with no rescue; if the callback raised, the handle stayed pending (so `wait` blocked until its timeout and raised `WaitTimeoutError` for a message that was actually delivered) and the exception unwound out of the FFI callback on librdkafka's polling thread (`abort_on_exception = true`), taking down the whole process. The user callback is now wrapped so exceptions are logged and swallowed (matching the rebalance callback) and the handle is always unlocked in an `ensure`.
|
|
24
|
+
- [Fix] Stop admin operations (`describe_configs`, `incremental_alter_configs`, `list_offsets`) from leaking native resources when their arguments are rejected. Each parsed user input (`.fetch`/offset validation) only after allocating the background queue, `AdminOptions`, the registered handle and per-resource native objects, so a `KeyError`/`ArgumentError` leaked all of them. Input is now fully parsed and validated before any native allocation.
|
|
25
|
+
- [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. `rd_kafka_ConfigResource_add_incremental_config` returns an `rd_kafka_error_t` for an invalid op_type, an empty/nil name, or a nil value on a non-delete op; the result was ignored, so the entry was dropped, the alter request still reported success, and the error object leaked. The error is now surfaced as an `RdkafkaError` (raised before the request is sent) and the native error object is freed.
|
|
27
|
+
- [Fix] Allocate the admin result-count out-parameter as `:size_t` instead of `:int32`. Every librdkafka `rd_kafka_*_result_*(result, size_t *cntp)` accessor writes a full native `size_t` (8 bytes on 64-bit), but the count pointer was a 4-byte `FFI::MemoryPointer.new(:int32)` across the create/delete topic, create partitions, create/delete ACL, describe/incremental-alter configs and config-synonyms paths - a 4-byte heap overflow on every admin result parse (benign on little-endian, where the low word still reads the correct count, but undefined behavior). Now uses `:size_t`.
|
|
28
|
+
- [Fix] Stabilize the flaky `Consumer#lag` "calculates the consumer lag" spec on overloaded CI (e.g. macOS). The manual `consumer.commit` could raise `no_offset` when the default 5s background auto-commit had already committed the stored offsets, or when the auto offset store had not yet caught up with `poll`. The spec now raises `auto.commit.interval.ms` to 60s (matching the existing `#seek`/pause specs) and lets the offset store settle before committing.
|
|
29
|
+
- [Enhancement] Expose `replicas` and `isrs` (in-sync replica broker ids) on each partition in topic metadata (`Metadata#topics` partition hashes). The base struct `#to_h` skips FFI pointer members, so these two arrays were dropped entirely and the partition replica assignment was unavailable to callers (e.g. for planning replication-factor changes). `PartitionMetadata#to_h` now dereferences both pointers into arrays of broker ids.
|
|
30
|
+
- [Fix] Resolve admin operation handles from the event error when an admin operation fails at the operation level (e.g. brokers unreachable, or the client closed with the request in flight). librdkafka delivers such failures as a result event with the error set and an empty results array, but the create topic, delete topic, create partitions, delete groups, create ACL and delete ACL handlers indexed `results[0]` unconditionally. That raised inside the background event callback, so the handle was never unlocked and `wait` blocked until its own timeout and raised `WaitTimeoutError`, discarding the real error. These handlers now check the event error first and resolve the handle with the actual error code (the describe configs, incremental alter configs, describe ACL and list offsets handlers already did).
|
|
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.
|
|
35
|
+
|
|
36
|
+
## 0.28.0 (2026-06-03)
|
|
37
|
+
- [Enhancement] Bump librdkafka to `2.14.1`
|
|
38
|
+
- [Enhancement] Replace version-gated `Warning[:performance]` with dynamic `Warning.categories` opt-in in spec helper so new Ruby warning categories are automatically enabled without manual updates.
|
|
39
|
+
- [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.
|
|
40
|
+
|
|
41
|
+
## 0.27.0 (2026-05-07)
|
|
42
|
+
- [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`.
|
|
43
|
+
- [Feature] Add `Config#describe_properties` to dump all librdkafka configuration properties (including defaults and hidden properties) as a Hash via `rd_kafka_conf_dump`.
|
|
44
|
+
- [Enhancement] Bump librdkafka to `2.14.0`
|
|
45
|
+
- [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.
|
|
46
|
+
- [Fix] Fix leaked queue reference in `Config#native_kafka` where `rd_kafka_queue_get_main` return value was not destroyed after passing to `rd_kafka_set_log_queue`.
|
|
47
|
+
- [Fix] Fix native topic partition list leak in `Consumer#position` where `tpl` was never destroyed.
|
|
48
|
+
|
|
49
|
+
## 0.26.0 (2026-04-02)
|
|
50
|
+
- [Enhancement] Bump librdkafka to `2.13.2`
|
|
51
|
+
- [Enhancement] Embed a per-file SPEC_HASH in test topic and consumer group names for tracing Kafka warnings back to specific spec files.
|
|
52
|
+
- [Fix] Register `ObjectSpace.define_finalizer` in `Rdkafka::Consumer` to prevent segfaults when a consumer is GC'd without being explicitly closed (jturkel).
|
|
53
|
+
- [Fix] Remove dead `#finalizer` instance methods from `Consumer` and `Admin` that could never work as GC finalizers.
|
|
54
|
+
- [Fix] Prevent cascading test failures in admin specs when a single handle leaks into the registry.
|
|
55
|
+
- [Feature] Extend `Rdkafka::RdkafkaError` with `instance_name` attribute containing the `rd_kafka_name` for tying errors back to specific native Kafka instances (#181).
|
|
56
|
+
|
|
57
|
+
## 0.25.1 (2026-02-26)
|
|
58
|
+
- [Feature] Support `rd_kafka_ListOffsets` admin API for querying partition offsets by specification (earliest, latest, max_timestamp, or by timestamp) without requiring a consumer group (#613).
|
|
59
|
+
- [Enhancement] Use native ARM64 runners instead of QEMU emulation for Alpine musl aarch64 builds, improving build performance and reliability.
|
|
60
|
+
- [Enhancement] Enable parallel compilation (`make -j$(nproc)`) for ARM64 Alpine musl builds.
|
|
61
|
+
- [Enhancement] Add file descriptor API for fiber scheduler integration. Expose `enable_queue_io_events` and `enable_background_queue_io_events` on `Consumer`, `Producer`, and `Admin` to enable non-blocking monitoring with select/poll/epoll for integration with Ruby fiber schedulers (Falcon, Async) and custom event loops.
|
|
62
|
+
- [Enhancement] Add non-blocking poll methods (`poll_nb`, `events_poll_nb`) on `Consumer` that skip GVL release for efficient fiber scheduler integration when using `poll(0)`.
|
|
63
|
+
- [Enhancement] Add `events_poll_nb_each` method on `Producer`, `Consumer`, and `Admin` for polling events in a single GVL/mutex session. Yields count after each iteration, caller returns `:stop` to break.
|
|
64
|
+
- [Enhancement] Add `poll_nb_each` method on `Consumer` for non-blocking message polling with proper resource cleanup, yielding each message and supporting early termination via `:stop` return value.
|
|
65
|
+
|
|
66
|
+
## 0.25.0 (2026-01-20)
|
|
67
|
+
- **[Deprecation]** `AbstractHandle#wait` parameter `max_wait_timeout:` (seconds) is deprecated in favor of `max_wait_timeout_ms:` (milliseconds). The old parameter still works but will be removed in v1.0.0.
|
|
68
|
+
- **[Deprecation]** `PartitionsCountCache` constructor parameter `ttl` (seconds) is deprecated in favor of `ttl_ms:` (milliseconds). The old parameter still works but will be removed in v1.0.0.
|
|
69
|
+
- [Enhancement] Extract all timeout defaults to `Rdkafka::Defaults` module for discoverability and per-call overrides (#310). All time-related values are now in milliseconds for consistency.
|
|
70
|
+
- [Enhancement] Add `timeout_ms` parameter to `Consumer#each` for configurable poll timeout.
|
|
71
|
+
- [Enhancement] Extract non-time configuration values (`METADATA_MAX_RETRIES`, `PARTITIONS_COUNT_CACHE_TTL_MS`) to `Rdkafka::Defaults` module.
|
|
72
|
+
- [Enhancement] Bump librdkafka to `2.12.1`
|
|
73
|
+
- [Enhancement] Add descriptive error messages for glibc compatibility issues with instructions for resolution (#654)
|
|
74
|
+
- [Enhancement] Replace magic numbers with named constants throughout codebase for improved readability and maintainability
|
|
75
|
+
|
|
76
|
+
## 0.24.2 (2025-10-31)
|
|
77
|
+
- [Enhancement] Force lock FFI to 1.17.1 or higher to include critical bug fixes around GCC, write barriers, and thread restarts for forks.
|
|
78
|
+
- [Fix] Fix for Core dump when providing extensions to oauthbearer_set_token (dssjoblom)
|
|
79
|
+
|
|
80
|
+
## 0.24.1 (2025-10-10)
|
|
81
|
+
- [Fix] Fix Github Action Ruby reference preventing non-compiled releases.
|
|
82
|
+
|
|
83
|
+
## 0.24.0 (2025-10-10)
|
|
84
|
+
- [Enhancement] Bump librdkafka to `2.11.1`
|
|
85
|
+
|
|
86
|
+
## 0.23.1 (2025-09-25)
|
|
87
|
+
- [Enhancement] Improve sigstore attestation for precompiled releases.
|
|
88
|
+
- [Fix] Fix incorrectly set default SSL certs dir.
|
|
89
|
+
- [Fix] Disable OpenSSL Heartbeats during compilation.
|
|
90
|
+
|
|
91
|
+
## 0.23.0 (2025-09-04)
|
|
92
|
+
- **[EOL]** Drop support for Ruby 3.1 to move forward with the fiber scheduler work.
|
|
93
|
+
- [Enhancement] Bump librdkafka to `2.11.0`
|
|
94
|
+
- [Enhancement] Support explicit Debian testing due to lib issues.
|
|
95
|
+
- [Enhancement] Support ARM64 Gnu precompilation.
|
|
96
|
+
- [Enhancement] Improve what symbols are exposed outside of the precompiled extensions.
|
|
97
|
+
- [Enhancement] Introduce an integration suite layer for non RSpec specs execution.
|
|
98
|
+
- [Fix] Add `json` gem as a dependency (was missing but used).
|
|
99
|
+
|
|
3
100
|
## 0.22.2 (2025-07-21)
|
|
4
101
|
- [Enhancement] Drastically increase number of platforms in the integration suite
|
|
5
102
|
- [Fix] Support Ubuntu `22.04` and older Alpine precompiled versions
|
|
6
103
|
- [Fix] FFI::DynamicLibrary.load_library': Could not open library
|
|
104
|
+
- [Change] Add new CI action to trigger auto-doc refresh.
|
|
7
105
|
|
|
8
106
|
## 0.22.1 (2025-07-17)
|
|
9
107
|
- [Fix] Fix `Rakefile` being available in the precompiled versions causing build failures.
|
|
@@ -38,7 +136,7 @@
|
|
|
38
136
|
- [Patch] Retire no longer needed cooperative-sticky patch.
|
|
39
137
|
|
|
40
138
|
## 0.19.0 (2024-10-01)
|
|
41
|
-
- **[
|
|
139
|
+
- **[EOL]** Drop Ruby 3.0 support
|
|
42
140
|
- [Enhancement] Update `librdkafka` to `2.5.3`
|
|
43
141
|
- [Enhancement] Use default oauth callback if none is passed (bachmanity1)
|
|
44
142
|
- [Fix] Fix incorrectly behaving CI on failures.
|
|
@@ -62,7 +160,7 @@
|
|
|
62
160
|
- [Fix] Switch to local release of librdkafka to mitigate its unavailability.
|
|
63
161
|
|
|
64
162
|
## 0.16.0 (2024-06-13)
|
|
65
|
-
- **[
|
|
163
|
+
- **[EOL]** Retire support for Ruby 2.7.
|
|
66
164
|
- **[Breaking]** Messages without headers returned by `#poll` contain frozen empty hash.
|
|
67
165
|
- **[Breaking]** `HashWithSymbolKeysTreatedLikeStrings` has been removed so headers are regular hashes with string keys.
|
|
68
166
|
- **[Feature]** Support incremental config describe + alter API.
|
|
@@ -123,7 +221,7 @@
|
|
|
123
221
|
- [Fix] Reference to Opaque is not released when Admin, Consumer or Producer is closed (mensfeld)
|
|
124
222
|
- [Fix] Trigger `#poll` on native kafka creation to handle oauthbearer cb (mensfeld)
|
|
125
223
|
- [Fix] `#flush` does not handle the timeouts errors by making it return `true` if all flushed or `false` if failed. We do **not** raise an exception here to keep it backwards compatible (mensfeld)
|
|
126
|
-
- [
|
|
224
|
+
- **[EOL]** Remove support for Ruby 2.6 due to it being EOL and WeakMap incompatibilities (mensfeld)
|
|
127
225
|
- [Change] Update Kafka Docker with Confluent KRaft (mensfeld)
|
|
128
226
|
- [Change] Update librdkafka repo reference from edenhill to confluentinc (mensfeld)
|
|
129
227
|
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Rdkafka
|
|
2
2
|
|
|
3
|
-
[](https://github.com/karafka/rdkafka-ruby/actions/workflows/ci_linux_x86_64_gnu.yml)
|
|
4
4
|
[](https://badge.fury.io/rb/rdkafka)
|
|
5
5
|
[](https://slack.karafka.io)
|
|
6
6
|
|
|
@@ -163,16 +163,23 @@ bundle exec rake produce_messages
|
|
|
163
163
|
|
|
164
164
|
| rdkafka-ruby | librdkafka | patches |
|
|
165
165
|
|-|-|-|
|
|
166
|
-
| 0.
|
|
167
|
-
| 0.
|
|
168
|
-
| 0.
|
|
169
|
-
| 0.
|
|
170
|
-
| 0.
|
|
171
|
-
| 0.
|
|
172
|
-
| 0.
|
|
173
|
-
| 0.
|
|
174
|
-
| 0.
|
|
175
|
-
| 0.
|
|
176
|
-
| 0.
|
|
177
|
-
| 0.
|
|
178
|
-
| 0.
|
|
166
|
+
| 0.29.x (2026-07-10) | 2.14.2 (2026-06-03) | yes |
|
|
167
|
+
| 0.28.x (2026-06-03) | 2.14.1 (2026-04-15) | yes |
|
|
168
|
+
| 0.27.x (2026-05-07) | 2.14.0 (2026-04-01) | yes |
|
|
169
|
+
| 0.26.x (2026-03-30) | 2.13.2 (2026-03-02) | yes |
|
|
170
|
+
| 0.25.x (2026-01-21) | 2.12.1 (2025-10-21) | yes |
|
|
171
|
+
| 0.24.x (2025-10-10) | 2.11.1 (2025-08-18) | yes |
|
|
172
|
+
| 0.23.x (2025-09-04) | 2.11.0 (2025-07-03) | yes |
|
|
173
|
+
| 0.22.x (2025-07-17) | 2.8.0 (2025-01-07) | yes |
|
|
174
|
+
| 0.21.x (2025-02-13) | 2.8.0 (2025-01-07) | yes |
|
|
175
|
+
| 0.20.0 (2025-01-07) | 2.6.1 (2024-11-18) | yes |
|
|
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-06-10) | yes |
|
|
178
|
+
| 0.17.0 (2024-08-03) | 2.4.0 (2024-05-07) | no |
|
|
179
|
+
| 0.16.0 (2024-06-13) | 2.3.0 (2023-10-25) | no |
|
|
180
|
+
| 0.15.0 (2023-12-03) | 2.3.0 (2023-10-25) | no |
|
|
181
|
+
| 0.14.0 (2023-11-21) | 2.2.0 (2023-07-12) | no |
|
|
182
|
+
| 0.13.0 (2023-07-24) | 2.0.2 (2023-01-20) | no |
|
|
183
|
+
| 0.12.0 (2022-06-17) | 1.9.0 (2022-06-16) | no |
|
|
184
|
+
| 0.11.0 (2021-11-17) | 1.8.2 (2021-10-18) | no |
|
|
185
|
+
| 0.10.0 (2021-09-07) | 1.5.0 (2020-07-20) | no |
|
data/Rakefile
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
4
|
require "./lib/rdkafka"
|
|
5
5
|
|
|
6
|
-
desc
|
|
6
|
+
desc "Generate some message traffic"
|
|
7
7
|
task :produce_messages do
|
|
8
|
-
config = {
|
|
8
|
+
config = { "bootstrap.servers": "localhost:9092" }
|
|
9
9
|
if ENV["DEBUG"]
|
|
10
10
|
config[:debug] = "broker,topic,msg"
|
|
11
11
|
end
|
|
@@ -15,24 +15,24 @@ task :produce_messages do
|
|
|
15
15
|
100.times do |i|
|
|
16
16
|
puts "Producing message #{i}"
|
|
17
17
|
delivery_handles << producer.produce(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
topic: "rake_test_topic",
|
|
19
|
+
payload: "Payload #{i} from Rake",
|
|
20
|
+
key: "Key #{i} from Rake"
|
|
21
21
|
)
|
|
22
22
|
end
|
|
23
|
-
puts
|
|
23
|
+
puts "Waiting for delivery"
|
|
24
24
|
delivery_handles.each(&:wait)
|
|
25
|
-
puts
|
|
25
|
+
puts "Done"
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
desc
|
|
28
|
+
desc "Consume some messages"
|
|
29
29
|
task :consume_messages do
|
|
30
30
|
config = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
"bootstrap.servers": "localhost:9092",
|
|
32
|
+
"group.id": "rake_test",
|
|
33
|
+
"enable.partition.eof": false,
|
|
34
|
+
"auto.offset.reset": "earliest",
|
|
35
|
+
"statistics.interval.ms": 10_000
|
|
36
36
|
}
|
|
37
37
|
if ENV["DEBUG"]
|
|
38
38
|
config[:debug] = "cgrp,topic,fetch"
|
|
@@ -40,7 +40,7 @@ task :consume_messages do
|
|
|
40
40
|
Rdkafka::Config.statistics_callback = lambda do |stats|
|
|
41
41
|
puts stats
|
|
42
42
|
end
|
|
43
|
-
|
|
43
|
+
Rdkafka::Config.new(config).consumer
|
|
44
44
|
consumer = Rdkafka::Config.new(config).consumer
|
|
45
45
|
consumer.subscribe("rake_test_topic")
|
|
46
46
|
consumer.each do |message|
|
|
@@ -48,14 +48,14 @@ task :consume_messages do
|
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
desc
|
|
51
|
+
desc "Hammer down"
|
|
52
52
|
task :load_test do
|
|
53
53
|
puts "Starting load test"
|
|
54
54
|
|
|
55
55
|
config = Rdkafka::Config.new(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
"bootstrap.servers": "localhost:9092",
|
|
57
|
+
"group.id": "load-test",
|
|
58
|
+
"enable.partition.eof": false
|
|
59
59
|
)
|
|
60
60
|
|
|
61
61
|
# Create a producer in a thread
|
|
@@ -65,9 +65,9 @@ task :load_test do
|
|
|
65
65
|
handles = []
|
|
66
66
|
1000.times do |i|
|
|
67
67
|
handles.push(producer.produce(
|
|
68
|
-
topic:
|
|
68
|
+
topic: "load_test_topic",
|
|
69
69
|
payload: "Payload #{i}",
|
|
70
|
-
key:
|
|
70
|
+
key: "Key #{i}"
|
|
71
71
|
))
|
|
72
72
|
end
|
|
73
73
|
handles.each(&:wait)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Checks Kafka logs for unsupported warning patterns
|
|
4
|
+
# Only specified warnings are allowed, all others should trigger failure
|
|
5
|
+
|
|
6
|
+
allowed_patterns=(
|
|
7
|
+
"Performing controller activation"
|
|
8
|
+
"registered with feature metadata.version"
|
|
9
|
+
"Replayed TopicRecord for"
|
|
10
|
+
"Replayed PartitionRecord for"
|
|
11
|
+
"Previous leader None and previous leader epoch"
|
|
12
|
+
"Creating new"
|
|
13
|
+
"Unloaded transaction metadata"
|
|
14
|
+
"closing connection"
|
|
15
|
+
"sent a heartbeat request but received error REQUEST_TIMED_OUT"
|
|
16
|
+
"Topic '__consumer_offsets' already exists"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
# Get all warnings
|
|
20
|
+
warnings=$(docker logs --since=0 kafka | grep "] WARN ")
|
|
21
|
+
exit_code=0
|
|
22
|
+
|
|
23
|
+
while IFS= read -r line; do
|
|
24
|
+
allowed=0
|
|
25
|
+
for pattern in "${allowed_patterns[@]}"; do
|
|
26
|
+
if echo "$line" | grep -q "$pattern"; then
|
|
27
|
+
allowed=1
|
|
28
|
+
break
|
|
29
|
+
fi
|
|
30
|
+
done
|
|
31
|
+
|
|
32
|
+
if [ $allowed -eq 0 ]; then
|
|
33
|
+
echo "Unexpected warning found:"
|
|
34
|
+
echo "$line"
|
|
35
|
+
exit_code=1
|
|
36
|
+
fi
|
|
37
|
+
done <<< "$warnings"
|
|
38
|
+
|
|
39
|
+
exit $exit_code
|
|
Binary file
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
services:
|
|
2
|
+
kafka:
|
|
3
|
+
container_name: kafka
|
|
4
|
+
image: confluentinc/cp-kafka:8.3.0
|
|
5
|
+
ports:
|
|
6
|
+
- 9092:9092 # Support PLAINTEXT so we can run one docker setup for SSL and PLAINTEXT
|
|
7
|
+
- 9093:9093
|
|
8
|
+
volumes:
|
|
9
|
+
- ./ssl:/etc/kafka/secrets
|
|
10
|
+
environment:
|
|
11
|
+
CLUSTER_ID: kafka-docker-cluster-1
|
|
12
|
+
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
|
13
|
+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
|
14
|
+
KAFKA_PROCESS_ROLES: broker,controller
|
|
15
|
+
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
|
|
16
|
+
KAFKA_LISTENERS: PLAINTEXT://:9092,SSL://:9093,CONTROLLER://:9094
|
|
17
|
+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL
|
|
18
|
+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092,SSL://127.0.0.1:9093
|
|
19
|
+
KAFKA_BROKER_ID: 1
|
|
20
|
+
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@127.0.0.1:9094
|
|
21
|
+
ALLOW_PLAINTEXT_LISTENER: 'yes'
|
|
22
|
+
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false'
|
|
23
|
+
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
|
|
24
|
+
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
|
|
25
|
+
KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: "true"
|
|
26
|
+
KAFKA_AUTHORIZER_CLASS_NAME: org.apache.kafka.metadata.authorizer.StandardAuthorizer
|
|
27
|
+
|
|
28
|
+
# SSL Configuration
|
|
29
|
+
KAFKA_SSL_KEYSTORE_FILENAME: kafka.server.keystore.jks
|
|
30
|
+
KAFKA_SSL_KEYSTORE_CREDENTIALS: kafka_keystore_creds
|
|
31
|
+
KAFKA_SSL_KEY_CREDENTIALS: kafka_ssl_key_creds
|
|
32
|
+
KAFKA_SSL_TRUSTSTORE_FILENAME: kafka.server.truststore.jks
|
|
33
|
+
KAFKA_SSL_TRUSTSTORE_CREDENTIALS: kafka_truststore_creds
|
|
34
|
+
KAFKA_SSL_CLIENT_AUTH: none
|
|
35
|
+
KAFKA_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM: ""
|
data/docker-compose.yml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
services:
|
|
2
2
|
kafka:
|
|
3
3
|
container_name: kafka
|
|
4
|
-
image: confluentinc/cp-kafka:8.
|
|
4
|
+
image: confluentinc/cp-kafka:8.3.0
|
|
5
5
|
|
|
6
6
|
ports:
|
|
7
7
|
- 9092:9092
|
|
@@ -18,7 +18,7 @@ services:
|
|
|
18
18
|
KAFKA_BROKER_ID: 1
|
|
19
19
|
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@127.0.0.1:9093
|
|
20
20
|
ALLOW_PLAINTEXT_LISTENER: 'yes'
|
|
21
|
-
KAFKA_AUTO_CREATE_TOPICS_ENABLE: '
|
|
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
24
|
KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: "true"
|
data/ext/Rakefile
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require File.expand_path(
|
|
3
|
+
require File.expand_path("../../lib/rdkafka/version", __FILE__)
|
|
4
4
|
require "digest"
|
|
5
5
|
require "fileutils"
|
|
6
6
|
require "open-uri"
|
|
7
7
|
|
|
8
|
-
task :
|
|
8
|
+
task default: :clean do
|
|
9
9
|
# For nix users, nix can't locate the file paths because the packages it's requiring aren't managed by the system but are
|
|
10
10
|
# managed by nix itself, so using the normal file paths doesn't work for nix users.
|
|
11
11
|
#
|
|
12
12
|
# Mini_portile causes an issue because it's dependencies are downloaded on the fly and therefore don't exist/aren't
|
|
13
13
|
# accessible in the nix environment
|
|
14
|
-
if ENV.fetch(
|
|
14
|
+
if ENV.fetch("RDKAFKA_EXT_PATH", "").empty?
|
|
15
15
|
# Download and compile librdkafka if RDKAFKA_EXT_PATH is not set
|
|
16
16
|
require "mini_portile2"
|
|
17
17
|
recipe = MiniPortile.new("librdkafka", Rdkafka::LIBRDKAFKA_VERSION)
|
|
18
18
|
|
|
19
19
|
# Use default homebrew openssl if we're on mac and the directory exists, is not using nix-prepared libraries
|
|
20
20
|
# and each of flags is not already set
|
|
21
|
-
if recipe.host&.include?("darwin") && system("which brew &> /dev/null") && Dir.exist?(
|
|
21
|
+
if recipe.host&.include?("darwin") && system("which brew &> /dev/null") && Dir.exist?((homebrew_prefix = `brew --prefix openssl`.strip).to_s) && !ENV.key?("NIX_LDFLAGS")
|
|
22
22
|
ENV["CPPFLAGS"] = "-I#{homebrew_prefix}/include" unless ENV.key?("CPPFLAGS")
|
|
23
23
|
ENV["LDFLAGS"] = "-L#{homebrew_prefix}/lib" unless ENV.key?("LDFLAGS")
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
releases = File.expand_path(File.join(File.dirname(__FILE__),
|
|
26
|
+
releases = File.expand_path(File.join(File.dirname(__FILE__), "../dist"))
|
|
27
27
|
|
|
28
28
|
recipe.files << {
|
|
29
|
-
:
|
|
30
|
-
:
|
|
29
|
+
url: "file://#{releases}/librdkafka-#{Rdkafka::LIBRDKAFKA_VERSION}.tar.gz",
|
|
30
|
+
sha256: Rdkafka::LIBRDKAFKA_SOURCE_SHA256
|
|
31
31
|
}
|
|
32
32
|
recipe.configure_options = ["--host=#{recipe.host}"]
|
|
33
33
|
|
|
34
|
-
recipe.patch_files = Dir[File.join(releases,
|
|
34
|
+
recipe.patch_files = Dir[File.join(releases, "patches", "*.patch")].sort
|
|
35
35
|
|
|
36
36
|
# Disable using libc regex engine in favor of the embedded one
|
|
37
37
|
# The default regex engine of librdkafka does not always work exactly as most of the users
|
|
38
38
|
# would expect, hence this flag allows for changing it to the other one
|
|
39
|
-
if ENV.key?(
|
|
40
|
-
recipe.configure_options <<
|
|
39
|
+
if ENV.key?("RDKAFKA_DISABLE_REGEX_EXT")
|
|
40
|
+
recipe.configure_options << "--disable-regex-ext"
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
recipe.cook
|
|
44
44
|
# Move dynamic library we're interested in
|
|
45
|
-
if recipe.host.include?(
|
|
46
|
-
from_extension =
|
|
47
|
-
to_extension
|
|
45
|
+
if recipe.host.include?("darwin")
|
|
46
|
+
from_extension = "1.dylib"
|
|
47
|
+
to_extension = "dylib"
|
|
48
48
|
else
|
|
49
|
-
from_extension =
|
|
50
|
-
to_extension =
|
|
49
|
+
from_extension = "so.1"
|
|
50
|
+
to_extension = "so"
|
|
51
51
|
end
|
|
52
52
|
lib_path = File.join(File.dirname(__FILE__), "ports/#{recipe.host}/librdkafka/#{Rdkafka::LIBRDKAFKA_VERSION}/lib/librdkafka.#{from_extension}")
|
|
53
53
|
FileUtils.mv(lib_path, File.join(File.dirname(__FILE__), "librdkafka.#{to_extension}"))
|
|
@@ -56,12 +56,12 @@ task :default => :clean do
|
|
|
56
56
|
FileUtils.rm_rf File.join(File.dirname(__FILE__), "ports")
|
|
57
57
|
else
|
|
58
58
|
# Otherwise, copy existing libraries to ./ext
|
|
59
|
-
if ENV[
|
|
59
|
+
if ENV["RDKAFKA_EXT_PATH"].nil? || ENV["RDKAFKA_EXT_PATH"].empty?
|
|
60
60
|
raise "RDKAFKA_EXT_PATH must be set in your nix config when running under nix"
|
|
61
61
|
end
|
|
62
62
|
files = [
|
|
63
|
-
File.join(ENV[
|
|
64
|
-
File.join(ENV[
|
|
63
|
+
File.join(ENV["RDKAFKA_EXT_PATH"], "lib", "librdkafka.dylib"),
|
|
64
|
+
File.join(ENV["RDKAFKA_EXT_PATH"], "lib", "librdkafka.so")
|
|
65
65
|
]
|
|
66
66
|
files.each { |ext| FileUtils.cp(ext, File.dirname(__FILE__)) if File.exist?(ext) }
|
|
67
67
|
end
|
|
@@ -76,28 +76,28 @@ end
|
|
|
76
76
|
|
|
77
77
|
namespace :dist do
|
|
78
78
|
task :dir do
|
|
79
|
-
ENV["RDKAFKA_DIST_PATH"] ||= File.expand_path(File.join(File.dirname(__FILE__),
|
|
79
|
+
ENV["RDKAFKA_DIST_PATH"] ||= File.expand_path(File.join(File.dirname(__FILE__), "..", "dist"))
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
task :
|
|
82
|
+
task file: "dist:dir" do
|
|
83
83
|
ENV["RDKAFKA_DIST_FILE"] ||= File.join(ENV["RDKAFKA_DIST_PATH"], "librdkafka_#{Rdkafka::LIBRDKAFKA_VERSION}.tar.gz")
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
task :
|
|
87
|
-
Dir.glob(File.join(
|
|
86
|
+
task clean: "dist:file" do
|
|
87
|
+
Dir.glob(File.join(ENV["RDKAFKA_DIST_PATH"].to_s, "*")).each do |filename|
|
|
88
88
|
next if filename.include? ENV["RDKAFKA_DIST_FILE"]
|
|
89
89
|
|
|
90
90
|
FileUtils.rm_rf filename
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
task :
|
|
94
|
+
task download: "dist:file" do
|
|
95
95
|
version = Rdkafka::LIBRDKAFKA_VERSION
|
|
96
96
|
librdkafka_download = "https://codeload.github.com/confluentinc/librdkafka/tar.gz/v#{version}"
|
|
97
97
|
|
|
98
98
|
URI.open(librdkafka_download) do |file|
|
|
99
99
|
filename = ENV["RDKAFKA_DIST_FILE"]
|
|
100
|
-
data
|
|
100
|
+
data = file.read
|
|
101
101
|
|
|
102
102
|
if Digest::SHA256.hexdigest(data) != Rdkafka::LIBRDKAFKA_SOURCE_SHA256
|
|
103
103
|
raise "SHA256 does not match downloaded file"
|
|
@@ -107,7 +107,7 @@ namespace :dist do
|
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
task :
|
|
110
|
+
task update: %w[dist:download dist:clean]
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
namespace :build do
|
|
@@ -118,8 +118,8 @@ namespace :build do
|
|
|
118
118
|
|
|
119
119
|
recipe = MiniPortile.new("librdkafka", version)
|
|
120
120
|
recipe.files << "https://github.com/confluentinc/librdkafka/archive/#{ref}.tar.gz"
|
|
121
|
-
recipe.configure_options = ["--host=#{recipe.host}","--enable-static", "--enable-zstd"]
|
|
122
|
-
recipe.patch_files = Dir[File.join(releases,
|
|
121
|
+
recipe.configure_options = ["--host=#{recipe.host}", "--enable-static", "--enable-zstd"]
|
|
122
|
+
recipe.patch_files = Dir[File.join(releases, "patches", "*.patch")].sort
|
|
123
123
|
recipe.cook
|
|
124
124
|
|
|
125
125
|
ext = recipe.host.include?("darwin") ? "dylib" : "so"
|