rdkafka 0.22.0.beta1-x86_64-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/CODEOWNERS +3 -0
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/ci_linux_x86_64_gnu.yml +249 -0
- data/.github/workflows/ci_linux_x86_64_musl.yml +205 -0
- data/.github/workflows/ci_macos_arm64.yml +306 -0
- data/.github/workflows/push_linux_x86_64_gnu.yml +64 -0
- data/.github/workflows/push_linux_x86_64_musl.yml +77 -0
- data/.github/workflows/push_macos_arm64.yml +54 -0
- data/.github/workflows/push_ruby.yml +37 -0
- data/.github/workflows/verify-action-pins.yml +16 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.yardopts +2 -0
- data/CHANGELOG.md +247 -0
- data/Gemfile +5 -0
- data/MIT-LICENSE +22 -0
- data/README.md +178 -0
- data/Rakefile +96 -0
- data/docker-compose.yml +25 -0
- data/ext/README.md +19 -0
- data/ext/Rakefile +131 -0
- data/ext/build_common.sh +361 -0
- data/ext/build_linux_x86_64_gnu.sh +306 -0
- data/ext/build_linux_x86_64_musl.sh +763 -0
- data/ext/build_macos_arm64.sh +550 -0
- data/ext/librdkafka.so +0 -0
- data/lib/rdkafka/abstract_handle.rb +116 -0
- data/lib/rdkafka/admin/acl_binding_result.rb +51 -0
- data/lib/rdkafka/admin/config_binding_result.rb +30 -0
- data/lib/rdkafka/admin/config_resource_binding_result.rb +18 -0
- data/lib/rdkafka/admin/create_acl_handle.rb +28 -0
- data/lib/rdkafka/admin/create_acl_report.rb +24 -0
- data/lib/rdkafka/admin/create_partitions_handle.rb +27 -0
- data/lib/rdkafka/admin/create_partitions_report.rb +6 -0
- data/lib/rdkafka/admin/create_topic_handle.rb +29 -0
- data/lib/rdkafka/admin/create_topic_report.rb +24 -0
- data/lib/rdkafka/admin/delete_acl_handle.rb +30 -0
- data/lib/rdkafka/admin/delete_acl_report.rb +23 -0
- data/lib/rdkafka/admin/delete_groups_handle.rb +28 -0
- data/lib/rdkafka/admin/delete_groups_report.rb +24 -0
- data/lib/rdkafka/admin/delete_topic_handle.rb +29 -0
- data/lib/rdkafka/admin/delete_topic_report.rb +24 -0
- data/lib/rdkafka/admin/describe_acl_handle.rb +30 -0
- data/lib/rdkafka/admin/describe_acl_report.rb +24 -0
- data/lib/rdkafka/admin/describe_configs_handle.rb +33 -0
- data/lib/rdkafka/admin/describe_configs_report.rb +54 -0
- data/lib/rdkafka/admin/incremental_alter_configs_handle.rb +33 -0
- data/lib/rdkafka/admin/incremental_alter_configs_report.rb +54 -0
- data/lib/rdkafka/admin.rb +833 -0
- data/lib/rdkafka/bindings.rb +566 -0
- data/lib/rdkafka/callbacks.rb +415 -0
- data/lib/rdkafka/config.rb +398 -0
- data/lib/rdkafka/consumer/headers.rb +79 -0
- data/lib/rdkafka/consumer/message.rb +86 -0
- data/lib/rdkafka/consumer/partition.rb +51 -0
- data/lib/rdkafka/consumer/topic_partition_list.rb +169 -0
- data/lib/rdkafka/consumer.rb +653 -0
- data/lib/rdkafka/error.rb +101 -0
- data/lib/rdkafka/helpers/oauth.rb +58 -0
- data/lib/rdkafka/helpers/time.rb +14 -0
- data/lib/rdkafka/metadata.rb +115 -0
- data/lib/rdkafka/native_kafka.rb +139 -0
- data/lib/rdkafka/producer/delivery_handle.rb +40 -0
- data/lib/rdkafka/producer/delivery_report.rb +46 -0
- data/lib/rdkafka/producer/partitions_count_cache.rb +216 -0
- data/lib/rdkafka/producer.rb +430 -0
- data/lib/rdkafka/version.rb +7 -0
- data/lib/rdkafka.rb +54 -0
- data/rdkafka.gemspec +65 -0
- data/renovate.json +92 -0
- data/spec/rdkafka/abstract_handle_spec.rb +117 -0
- data/spec/rdkafka/admin/create_acl_handle_spec.rb +56 -0
- data/spec/rdkafka/admin/create_acl_report_spec.rb +18 -0
- data/spec/rdkafka/admin/create_topic_handle_spec.rb +52 -0
- data/spec/rdkafka/admin/create_topic_report_spec.rb +16 -0
- data/spec/rdkafka/admin/delete_acl_handle_spec.rb +85 -0
- data/spec/rdkafka/admin/delete_acl_report_spec.rb +72 -0
- data/spec/rdkafka/admin/delete_topic_handle_spec.rb +52 -0
- data/spec/rdkafka/admin/delete_topic_report_spec.rb +16 -0
- data/spec/rdkafka/admin/describe_acl_handle_spec.rb +85 -0
- data/spec/rdkafka/admin/describe_acl_report_spec.rb +73 -0
- data/spec/rdkafka/admin_spec.rb +770 -0
- data/spec/rdkafka/bindings_spec.rb +223 -0
- data/spec/rdkafka/callbacks_spec.rb +20 -0
- data/spec/rdkafka/config_spec.rb +258 -0
- data/spec/rdkafka/consumer/headers_spec.rb +73 -0
- data/spec/rdkafka/consumer/message_spec.rb +139 -0
- data/spec/rdkafka/consumer/partition_spec.rb +57 -0
- data/spec/rdkafka/consumer/topic_partition_list_spec.rb +248 -0
- data/spec/rdkafka/consumer_spec.rb +1274 -0
- data/spec/rdkafka/error_spec.rb +89 -0
- data/spec/rdkafka/metadata_spec.rb +79 -0
- data/spec/rdkafka/native_kafka_spec.rb +130 -0
- data/spec/rdkafka/producer/delivery_handle_spec.rb +45 -0
- data/spec/rdkafka/producer/delivery_report_spec.rb +25 -0
- data/spec/rdkafka/producer/partitions_count_cache_spec.rb +359 -0
- data/spec/rdkafka/producer_spec.rb +1052 -0
- data/spec/spec_helper.rb +195 -0
- metadata +276 -0
data/CHANGELOG.md
ADDED
@@ -0,0 +1,247 @@
|
|
1
|
+
# Rdkafka Changelog
|
2
|
+
|
3
|
+
## 0.22.0 (Unreleased)
|
4
|
+
- **[Feature]** Add precompiled `x86_64-linux-gnu` setup.
|
5
|
+
- **[Feature]** Add precompiled `x86_64-linux-musl` setup.
|
6
|
+
- **[Feature]** Add precompiled `macos_arm64` setup.
|
7
|
+
- [Fix] Fix a case where using empty key on the `musl` architecture would cause a segfault.
|
8
|
+
- [Enhancement] Allow for producing to non-existing topics with `key` and `partition_key` present.
|
9
|
+
- [Enhancement] Replace TTL-based partition count cache with a global cache that reuses `librdkafka` statistics data when possible.
|
10
|
+
- [Enhancement] Support producing and consuming of headers with mulitple values (KIP-82).
|
11
|
+
- [Enhancement] Allow native Kafka customization poll time.
|
12
|
+
- [Enhancement] Roll out experimental jruby support.
|
13
|
+
- [Enhancement] Run all specs on each of the platforms with and without precompilation.
|
14
|
+
- [Fix] Fix issue where post-closed producer C topics refs would not be cleaned.
|
15
|
+
- [Fix] Fiber causes Segmentation Fault.
|
16
|
+
- [Change] Move to trusted-publishers and remove signing since no longer needed.
|
17
|
+
|
18
|
+
**Note**: Precompiled extensions are a new feature in this release. While they significantly improve installation speed and reduce build dependencies, they should be thoroughly tested in your staging environment before deploying to production. If you encounter any issues with precompiled extensions, you can fall back to building from sources.
|
19
|
+
|
20
|
+
## 0.21.0 (2025-02-13)
|
21
|
+
- [Enhancement] Bump librdkafka to `2.8.0`
|
22
|
+
|
23
|
+
## 0.20.0 (2025-01-07)
|
24
|
+
- **[Breaking]** Deprecate and remove `#each_batch` due to data consistency concerns.
|
25
|
+
- [Enhancement] Bump librdkafka to `2.6.1`
|
26
|
+
- [Enhancement] Expose `rd_kafka_global_init` to mitigate macos forking issues.
|
27
|
+
- [Enhancement] Avoid clobbering LDFLAGS and CPPFLAGS if in a nix prepared environment (secobarbital).
|
28
|
+
- [Patch] Retire no longer needed cooperative-sticky patch.
|
29
|
+
|
30
|
+
## 0.19.0 (2024-10-01)
|
31
|
+
- **[Breaking]** Drop Ruby 3.0 support
|
32
|
+
- [Enhancement] Update `librdkafka` to `2.5.3`
|
33
|
+
- [Enhancement] Use default oauth callback if none is passed (bachmanity1)
|
34
|
+
- [Fix] Fix incorrectly behaving CI on failures.
|
35
|
+
- [Patch] Patch with "Add forward declaration to fix compilation without ssl" fix
|
36
|
+
|
37
|
+
## 0.18.0 (2024-09-02)
|
38
|
+
- [Enhancement] Update `librdkafka` to `2.5.0`
|
39
|
+
- [Enhancement] Do not release GVL on `rd_kafka_name` (ferrous26)
|
40
|
+
- [Patch] Patch cooperative-sticky assignments in librdkafka.
|
41
|
+
- [Fix] Mitigate a case where FFI would not restart the background events callback dispatcher in forks
|
42
|
+
- [Fix] Fix unused variable reference in producer (lucasmvnascimento)
|
43
|
+
|
44
|
+
## 0.17.0 (2024-08-03)
|
45
|
+
- [Feature] Add `#seek_by` to be able to seek for a message by topic, partition and offset (zinahia)
|
46
|
+
- [Enhancement] Update `librdkafka` to `2.4.0`
|
47
|
+
- [Enhancement] Support ability to release patches to librdkafka.
|
48
|
+
- [Change] Remove old producer timeout API warnings.
|
49
|
+
- [Fix] Switch to local release of librdkafka to mitigate its unavailability.
|
50
|
+
|
51
|
+
## 0.16.1 (2024-07-10)
|
52
|
+
- [Fix] Switch to local release of librdkafka to mitigate its unavailability.
|
53
|
+
|
54
|
+
## 0.16.0 (2024-06-13)
|
55
|
+
- **[Breaking]** Retire support for Ruby 2.7.
|
56
|
+
- **[Breaking]** Messages without headers returned by `#poll` contain frozen empty hash.
|
57
|
+
- **[Breaking]** `HashWithSymbolKeysTreatedLikeStrings` has been removed so headers are regular hashes with string keys.
|
58
|
+
- **[Feature]** Support incremental config describe + alter API.
|
59
|
+
- **[Feature]** Oauthbearer token refresh callback (bruce-szalwinski-he)
|
60
|
+
- **[Feature]** Provide ability to use topic config on a producer for custom behaviors per dispatch.
|
61
|
+
- [Enhancement] Use topic config reference cache for messages production to prevent topic objects allocation with each message.
|
62
|
+
- [Enhancement] Provide `Rrdkafka::Admin#describe_errors` to get errors descriptions (mensfeld)
|
63
|
+
- [Enhancement] Replace time poll based wait engine with an event based to improve response times on blocking operations and wait (nijikon + mensfeld)
|
64
|
+
- [Enhancement] Allow for usage of the second regex engine of librdkafka by setting `RDKAFKA_DISABLE_REGEX_EXT` during build (mensfeld)
|
65
|
+
- [Enhancement] name polling Thread as `rdkafka.native_kafka#<name>` (nijikon)
|
66
|
+
- [Enhancement] Save two objects on message produced and lower CPU usage on message produced with small improvements.
|
67
|
+
- [Change] Allow for native kafka thread operations deferring and manual start for consumer, producer and admin.
|
68
|
+
- [Change] The `wait_timeout` argument in `AbstractHandle.wait` method is deprecated and will be removed in future versions without replacement. We don't rely on it's value anymore (nijikon)
|
69
|
+
- [Fix] Background logger stops working after forking causing memory leaks (mensfeld)
|
70
|
+
- [Fix] Fix bogus case/when syntax. Levels 1, 2, and 6 previously defaulted to UNKNOWN (jjowdy)
|
71
|
+
|
72
|
+
## 0.15.2 (2024-07-10)
|
73
|
+
- [Fix] Switch to local release of librdkafka to mitigate its unavailability.
|
74
|
+
|
75
|
+
## 0.15.1 (2024-01-30)
|
76
|
+
- [Enhancement] Provide support for Nix OS (alexandriainfantino)
|
77
|
+
- [Enhancement] Replace `rd_kafka_offset_store` with `rd_kafka_offsets_store` (mensfeld)
|
78
|
+
- [Enhancement] Alias `topic_name` as `topic` in the delivery report (mensfeld)
|
79
|
+
- [Enhancement] Provide `label` producer handler and report reference for improved traceability (mensfeld)
|
80
|
+
- [Enhancement] Include the error when invoking `create_result` on producer handle (mensfeld)
|
81
|
+
- [Enhancement] Skip intermediate array creation on delivery report callback execution (one per message) (mensfeld).
|
82
|
+
- [Enhancement] Report `-1` instead of `nil` in case `partition_count` failure (mensfeld).
|
83
|
+
- [Fix] Fix return type on `#rd_kafka_poll` (mensfeld)
|
84
|
+
- [Fix] `uint8_t` does not exist on Apple Silicon (mensfeld)
|
85
|
+
- [Fix] Missing ACL `RD_KAFKA_RESOURCE_BROKER` constant reference (mensfeld)
|
86
|
+
- [Fix] Partition cache caches invalid nil result for `PARTITIONS_COUNT_TTL` (mensfeld)
|
87
|
+
- [Change] Rename `matching_acl_pattern_type` to `matching_acl_resource_pattern_type` to align the whole API (mensfeld)
|
88
|
+
|
89
|
+
## 0.15.0 (2023-12-03)
|
90
|
+
- **[Feature]** Add `Admin#metadata` (mensfeld)
|
91
|
+
- **[Feature]** Add `Admin#create_partitions` (mensfeld)
|
92
|
+
- **[Feature]** Add `Admin#delete_group` utility (piotaixr)
|
93
|
+
- **[Feature]** Add Create and Delete ACL Feature To Admin Functions (vgnanasekaran)
|
94
|
+
- **[Feature]** Support `#assignment_lost?` on a consumer to check for involuntary assignment revocation (mensfeld)
|
95
|
+
- [Enhancement] Expose alternative way of managing consumer events via a separate queue (mensfeld)
|
96
|
+
- [Enhancement] **Bump** librdkafka to 2.3.0 (mensfeld)
|
97
|
+
- [Enhancement] Increase the `#lag` and `#query_watermark_offsets` default timeouts from 100ms to 1000ms. This will compensate for network glitches and remote clusters operations (mensfeld)
|
98
|
+
- [Change] Use `SecureRandom.uuid` instead of `random` for test consumer groups (mensfeld)
|
99
|
+
|
100
|
+
## 0.14.1 (2024-07-10)
|
101
|
+
- [Fix] Switch to local release of librdkafka to mitigate its unavailability.
|
102
|
+
|
103
|
+
## 0.14.0 (2023-11-21)
|
104
|
+
- [Enhancement] Add `raise_response_error` flag to the `Rdkafka::AbstractHandle`.
|
105
|
+
- [Enhancement] Allow for setting `statistics_callback` as nil to reset predefined settings configured by a different gem (mensfeld)
|
106
|
+
- [Enhancement] Get consumer position (thijsc & mensfeld)
|
107
|
+
- [Enhancement] Provide `#purge` to remove any outstanding requests from the producer (mensfeld)
|
108
|
+
- [Enhancement] Update `librdkafka` to `2.2.0` (mensfeld)
|
109
|
+
- [Enhancement] Introduce producer partitions count metadata cache (mensfeld)
|
110
|
+
- [Enhancement] Increase metadata timeout request from `250 ms` to `2000 ms` default to allow for remote cluster operations via `rdkafka-ruby` (mensfeld)
|
111
|
+
- [Enhancement] Introduce `#name` for producers and consumers (mensfeld)
|
112
|
+
- [Enhancement] Include backtrace in non-raised binded errors (mensfeld)
|
113
|
+
- [Fix] Reference to Opaque is not released when Admin, Consumer or Producer is closed (mensfeld)
|
114
|
+
- [Fix] Trigger `#poll` on native kafka creation to handle oauthbearer cb (mensfeld)
|
115
|
+
- [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)
|
116
|
+
- [Change] Remove support for Ruby 2.6 due to it being EOL and WeakMap incompatibilities (mensfeld)
|
117
|
+
- [Change] Update Kafka Docker with Confluent KRaft (mensfeld)
|
118
|
+
- [Change] Update librdkafka repo reference from edenhill to confluentinc (mensfeld)
|
119
|
+
|
120
|
+
## 0.13.1 (2024-07-10)
|
121
|
+
- [Fix] Switch to local release of librdkafka to mitigate its unavailability.
|
122
|
+
|
123
|
+
## 0.13.0 (2023-07-24)
|
124
|
+
- Support cooperative sticky partition assignment in the rebalance callback (methodmissing)
|
125
|
+
- Support both string and symbol header keys (ColinDKelley)
|
126
|
+
- Handle tombstone messages properly (kgalieva)
|
127
|
+
- Add topic name to delivery report (maeve)
|
128
|
+
- Allow string partitioner config (mollyegibson)
|
129
|
+
- Fix documented type for DeliveryReport#error (jimmydo)
|
130
|
+
- Bump librdkafka to 2.0.2 (lmaia)
|
131
|
+
- Use finalizers to cleanly exit producer and admin (thijsc)
|
132
|
+
- Lock access to the native kafka client (thijsc)
|
133
|
+
- Fix potential race condition in multi-threaded producer (mensfeld)
|
134
|
+
- Fix leaking FFI resources in specs (mensfeld)
|
135
|
+
- Improve specs stability (mensfeld)
|
136
|
+
- Make metadata request timeout configurable (mensfeld)
|
137
|
+
- call_on_partitions_assigned and call_on_partitions_revoked only get a tpl passed in (thijsc)
|
138
|
+
|
139
|
+
## 0.12.1 (2024-07-11)
|
140
|
+
- [Fix] Switch to local release of librdkafka to mitigate its unavailability.
|
141
|
+
|
142
|
+
## 0.12.0 (2022-06-17)
|
143
|
+
- Bumps librdkafka to 1.9.0
|
144
|
+
- Fix crash on empty partition key (mensfeld)
|
145
|
+
- Pass the delivery handle to the callback (gvisokinskas)
|
146
|
+
|
147
|
+
## 0.11.0 (2021-11-17)
|
148
|
+
- Upgrade librdkafka to 1.8.2
|
149
|
+
- Bump supported minimum Ruby version to 2.6
|
150
|
+
- Better homebrew path detection
|
151
|
+
|
152
|
+
## 0.10.0 (2021-09-07)
|
153
|
+
- Upgrade librdkafka to 1.5.0
|
154
|
+
- Add error callback config
|
155
|
+
|
156
|
+
## 0.9.0 (2021-06-23)
|
157
|
+
- Fixes for Ruby 3.0
|
158
|
+
- Allow any callable object for callbacks (gremerritt)
|
159
|
+
- Reduce memory allocations in Rdkafka::Producer#produce (jturkel)
|
160
|
+
- Use queue as log callback to avoid unsafe calls from trap context (breunigs)
|
161
|
+
- Allow passing in topic configuration on create_topic (dezka)
|
162
|
+
- Add each_batch method to consumer (mgrosso)
|
163
|
+
|
164
|
+
## 0.8.1 (2020-12-07)
|
165
|
+
- Fix topic_flag behaviour and add tests for Metadata (geoff2k)
|
166
|
+
- Add topic admin interface (geoff2k)
|
167
|
+
- Raise an exception if @native_kafka is nil (geoff2k)
|
168
|
+
- Option to use zstd compression (jasonmartens)
|
169
|
+
|
170
|
+
## 0.8.0 (2020-06-02)
|
171
|
+
- Upgrade librdkafka to 1.4.0
|
172
|
+
- Integrate librdkafka metadata API and add partition_key (by Adithya-copart)
|
173
|
+
- Ruby 2.7 compatibility fix (by Geoff Thé)A
|
174
|
+
- Add error to delivery report (by Alex Stanovsky)
|
175
|
+
- Don't override CPPFLAGS and LDFLAGS if already set on Mac (by Hiroshi Hatake)
|
176
|
+
- Allow use of Rake 13.x and up (by Tomasz Pajor)
|
177
|
+
|
178
|
+
## 0.7.0 (2019-09-21)
|
179
|
+
- Bump librdkafka to 1.2.0 (by rob-as)
|
180
|
+
- Allow customizing the wait time for delivery report availability (by mensfeld)
|
181
|
+
|
182
|
+
## 0.6.0 (2019-07-23)
|
183
|
+
- Bump librdkafka to 1.1.0 (by Chris Gaffney)
|
184
|
+
- Implement seek (by breunigs)
|
185
|
+
|
186
|
+
## 0.5.0 (2019-04-11)
|
187
|
+
- Bump librdkafka to 1.0.0 (by breunigs)
|
188
|
+
- Add cluster and member information (by dmexe)
|
189
|
+
- Support message headers for consumer & producer (by dmexe)
|
190
|
+
- Add consumer rebalance listener (by dmexe)
|
191
|
+
- Implement pause/resume partitions (by dmexe)
|
192
|
+
|
193
|
+
## 0.4.2 (2019-01-12)
|
194
|
+
- Delivery callback for producer
|
195
|
+
- Document list param of commit method
|
196
|
+
- Use default Homebrew openssl location if present
|
197
|
+
- Consumer lag handles empty topics
|
198
|
+
- End iteration in consumer when it is closed
|
199
|
+
- Add support for storing message offsets
|
200
|
+
- Add missing runtime dependency to rake
|
201
|
+
|
202
|
+
## 0.4.1 (2018-10-19)
|
203
|
+
- Bump librdkafka to 0.11.6
|
204
|
+
|
205
|
+
## 0.4.0 (2018-09-24)
|
206
|
+
- Improvements in librdkafka archive download
|
207
|
+
- Add global statistics callback
|
208
|
+
- Use Time for timestamps, potentially breaking change if you
|
209
|
+
rely on the previous behavior where it returns an integer with
|
210
|
+
the number of milliseconds.
|
211
|
+
- Bump librdkafka to 0.11.5
|
212
|
+
- Implement TopicPartitionList in Ruby so we don't have to keep
|
213
|
+
track of native objects.
|
214
|
+
- Support committing a topic partition list
|
215
|
+
- Add consumer assignment method
|
216
|
+
|
217
|
+
## 0.3.5 (2018-01-17)
|
218
|
+
- Fix crash when not waiting for delivery handles
|
219
|
+
- Run specs on Ruby 2.5
|
220
|
+
|
221
|
+
## 0.3.4 (2017-12-05)
|
222
|
+
- Bump librdkafka to 0.11.3
|
223
|
+
|
224
|
+
## 0.3.3 (2017-10-27)
|
225
|
+
- Fix bug that prevent display of `RdkafkaError` message
|
226
|
+
|
227
|
+
## 0.3.2 (2017-10-25)
|
228
|
+
- `add_topic` now supports using a partition count
|
229
|
+
- Add way to make errors clearer with an extra message
|
230
|
+
- Show topics in subscribe error message
|
231
|
+
- Show partition and topic in query watermark offsets error message
|
232
|
+
|
233
|
+
## 0.3.1 (2017-10-23)
|
234
|
+
- Bump librdkafka to 0.11.1
|
235
|
+
- Officially support ranges in `add_topic` for topic partition list.
|
236
|
+
- Add consumer lag calculator
|
237
|
+
|
238
|
+
## 0.3.0 (2017-10-17)
|
239
|
+
- Move both add topic methods to one `add_topic` in `TopicPartitionList`
|
240
|
+
- Add committed offsets to consumer
|
241
|
+
- Add query watermark offset to consumer
|
242
|
+
|
243
|
+
## 0.2.0 (2017-10-13)
|
244
|
+
- Some refactoring and add inline documentation
|
245
|
+
|
246
|
+
## 0.1.x (2017-09-10)
|
247
|
+
- Initial working version including producing and consuming
|
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017-2023 Thijs Cadier
|
4
|
+
2023, Maciej Mensfeld
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
# Rdkafka
|
2
|
+
|
3
|
+
[](https://github.com/karafka/rdkafka-ruby/actions/workflows/ci.yml)
|
4
|
+
[](https://badge.fury.io/rb/rdkafka)
|
5
|
+
[](https://slack.karafka.io)
|
6
|
+
|
7
|
+
> [!NOTE]
|
8
|
+
> The `rdkafka-ruby` gem was created and developed by [AppSignal](https://www.appsignal.com/). Their impactful contributions have significantly shaped the Ruby Kafka and Karafka ecosystems. For robust monitoring, we highly recommend AppSignal.
|
9
|
+
|
10
|
+
---
|
11
|
+
|
12
|
+
The `rdkafka` gem is a modern Kafka client library for Ruby based on
|
13
|
+
[librdkafka](https://github.com/confluentinc/librdkafka/).
|
14
|
+
It wraps the production-ready C client using the [ffi](https://github.com/ffi/ffi)
|
15
|
+
gem and targets Kafka 1.0+ and Ruby versions under security or
|
16
|
+
active maintenance. We remove a Ruby version from our CI builds when they
|
17
|
+
become EOL.
|
18
|
+
|
19
|
+
`rdkafka` was written because of the need for a reliable Ruby client for Kafka that supports modern Kafka at [AppSignal](https://appsignal.com). AppSignal runs it in production on very high-traffic systems.
|
20
|
+
|
21
|
+
The most essential pieces of a Kafka client are implemented, and we aim to provide all relevant consumer, producer, and admin APIs.
|
22
|
+
|
23
|
+
## Table of content
|
24
|
+
|
25
|
+
- [Project Scope](#project-scope)
|
26
|
+
- [Installation](#installation)
|
27
|
+
- [Usage](#usage)
|
28
|
+
* [Consuming Messages](#consuming-messages)
|
29
|
+
* [Producing Messages](#producing-messages)
|
30
|
+
- [Higher Level Libraries](#higher-level-libraries)
|
31
|
+
* [Message Processing Frameworks](#message-processing-frameworks)
|
32
|
+
* [Message Publishing Libraries](#message-publishing-libraries)
|
33
|
+
- [Forking](#forking)
|
34
|
+
- [Development](#development)
|
35
|
+
- [Example](#example)
|
36
|
+
- [Versions](#versions)
|
37
|
+
|
38
|
+
## Project Scope
|
39
|
+
|
40
|
+
While rdkafka-ruby aims to simplify the use of librdkafka in Ruby applications, it's important to understand the limitations of this library:
|
41
|
+
|
42
|
+
- **No Complex Producers/Consumers**: This library does not intend to offer complex producers or consumers. The aim is to stick closely to the functionalities provided by librdkafka itself.
|
43
|
+
|
44
|
+
- **Focus on librdkafka Capabilities**: Features that can be achieved directly in Ruby, without specific needs from librdkafka, are outside the scope of this library.
|
45
|
+
|
46
|
+
- **Existing High-Level Functionalities**: Certain high-level functionalities like producer metadata cache and simple consumer are already part of the library. Although they fall slightly outside the primary goal, they will remain part of the contract, given their existing usage.
|
47
|
+
|
48
|
+
|
49
|
+
## Installation
|
50
|
+
|
51
|
+
When installed, this gem downloads and compiles librdkafka. If you have any problems installing the gem, please open an issue.
|
52
|
+
|
53
|
+
## Usage
|
54
|
+
|
55
|
+
Please see the [documentation](https://karafka.io/docs/code/rdkafka-ruby/) for full details on how to use this gem. Below are two quick examples.
|
56
|
+
|
57
|
+
Unless you are seeking specific low-level capabilities, we **strongly** recommend using [Karafka](https://github.com/karafka/karafka) and [WaterDrop](https://github.com/karafka/waterdrop) when working with Kafka. These are higher-level libraries also maintained by us based on rdkafka-ruby.
|
58
|
+
|
59
|
+
### Consuming Messages
|
60
|
+
|
61
|
+
Subscribe to a topic and get messages. Kafka will automatically spread
|
62
|
+
the available partitions over consumers with the same group id.
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
config = {
|
66
|
+
:"bootstrap.servers" => "localhost:9092",
|
67
|
+
:"group.id" => "ruby-test"
|
68
|
+
}
|
69
|
+
consumer = Rdkafka::Config.new(config).consumer
|
70
|
+
consumer.subscribe("ruby-test-topic")
|
71
|
+
|
72
|
+
consumer.each do |message|
|
73
|
+
puts "Message received: #{message}"
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
77
|
+
### Producing Messages
|
78
|
+
|
79
|
+
Produce several messages, put the delivery handles in an array, and
|
80
|
+
wait for them before exiting. This way the messages will be batched and
|
81
|
+
efficiently sent to Kafka.
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
config = {:"bootstrap.servers" => "localhost:9092"}
|
85
|
+
producer = Rdkafka::Config.new(config).producer
|
86
|
+
delivery_handles = []
|
87
|
+
|
88
|
+
100.times do |i|
|
89
|
+
puts "Producing message #{i}"
|
90
|
+
delivery_handles << producer.produce(
|
91
|
+
topic: "ruby-test-topic",
|
92
|
+
payload: "Payload #{i}",
|
93
|
+
key: "Key #{i}"
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
delivery_handles.each(&:wait)
|
98
|
+
```
|
99
|
+
|
100
|
+
Note that creating a producer consumes some resources that will not be released until it `#close` is explicitly called, so be sure to call `Config#producer` only as necessary.
|
101
|
+
|
102
|
+
## Higher Level Libraries
|
103
|
+
|
104
|
+
Currently, there are two actively developed frameworks based on `rdkafka-ruby`, that provide higher-level API that can be used to work with Kafka messages and one library for publishing messages.
|
105
|
+
|
106
|
+
### Message Processing Frameworks
|
107
|
+
|
108
|
+
* [Karafka](https://github.com/karafka/karafka) - Ruby and Rails efficient Kafka processing framework.
|
109
|
+
* [Racecar](https://github.com/zendesk/racecar) - A simple framework for Kafka consumers in Ruby
|
110
|
+
|
111
|
+
### Message Publishing Libraries
|
112
|
+
|
113
|
+
* [WaterDrop](https://github.com/karafka/waterdrop) – Standalone Karafka library for producing Kafka messages.
|
114
|
+
|
115
|
+
## Forking
|
116
|
+
|
117
|
+
When working with `rdkafka-ruby`, it's essential to know that the underlying `librdkafka` library does not support fork-safe operations, even though it is thread-safe. Forking a process after initializing librdkafka clients can lead to unpredictable behavior due to inherited file descriptors and memory states. This limitation requires careful handling, especially in Ruby applications that rely on forking.
|
118
|
+
|
119
|
+
To address this, it's highly recommended to:
|
120
|
+
|
121
|
+
- Never initialize any `rdkafka-ruby` producers or consumers before forking to avoid state corruption.
|
122
|
+
- Before forking, always close any open producers or consumers if you've opened any.
|
123
|
+
- Use high-level libraries like [WaterDrop](https://github.com/karafka/waterdrop) and [Karafka](https://github.com/karafka/karafka/), which provide abstractions for handling librdkafka's intricacies.
|
124
|
+
|
125
|
+
## Development
|
126
|
+
|
127
|
+
Contributors are encouraged to focus on enhancements that align with the core goal of the library. We appreciate contributions but will likely not accept pull requests for features that:
|
128
|
+
|
129
|
+
- Implement functionalities that can achieved using standard Ruby capabilities without changes to the underlying rdkafka-ruby bindings.
|
130
|
+
- Deviate significantly from the primary aim of providing librdkafka bindings with Ruby-friendly interfaces.
|
131
|
+
|
132
|
+
A Docker Compose file is included to run Kafka. To run that:
|
133
|
+
|
134
|
+
```
|
135
|
+
docker-compose up
|
136
|
+
```
|
137
|
+
|
138
|
+
Run `bundle` and `cd ext && bundle exec rake && cd ..` to download and compile `librdkafka`.
|
139
|
+
|
140
|
+
You can then run `bundle exec rspec` to run the tests. To see rdkafka debug output:
|
141
|
+
|
142
|
+
```
|
143
|
+
DEBUG_PRODUCER=true bundle exec rspec
|
144
|
+
DEBUG_CONSUMER=true bundle exec rspec
|
145
|
+
```
|
146
|
+
|
147
|
+
After running the tests, you can bring the cluster down to start with a clean slate:
|
148
|
+
|
149
|
+
```
|
150
|
+
docker-compose down
|
151
|
+
```
|
152
|
+
|
153
|
+
## Example
|
154
|
+
|
155
|
+
To see everything working, run these in separate tabs:
|
156
|
+
|
157
|
+
```
|
158
|
+
bundle exec rake consume_messages
|
159
|
+
bundle exec rake produce_messages
|
160
|
+
```
|
161
|
+
|
162
|
+
## Versions
|
163
|
+
|
164
|
+
| rdkafka-ruby | librdkafka | patches |
|
165
|
+
|-|-|-|
|
166
|
+
| 0.22.x (2025-02-13) | 2.8.0 (Unreleased) | yes |
|
167
|
+
| 0.21.x (2025-02-13) | 2.8.0 (2025-01-07) | yes |
|
168
|
+
| 0.20.0 (2025-01-07) | 2.6.1 (2024-11-18) | yes |
|
169
|
+
| 0.19.0 (2024-10-01) | 2.5.3 (2024-09-02) | yes |
|
170
|
+
| 0.18.0 (2024-09-02) | 2.5.0 (2024-06-10) | yes |
|
171
|
+
| 0.17.0 (2024-08-03) | 2.4.0 (2024-05-07) | no |
|
172
|
+
| 0.16.0 (2024-06-13) | 2.3.0 (2023-10-25) | no |
|
173
|
+
| 0.15.0 (2023-12-03) | 2.3.0 (2023-10-25) | no |
|
174
|
+
| 0.14.0 (2023-11-21) | 2.2.0 (2023-07-12) | no |
|
175
|
+
| 0.13.0 (2023-07-24) | 2.0.2 (2023-01-20) | no |
|
176
|
+
| 0.12.0 (2022-06-17) | 1.9.0 (2022-06-16) | no |
|
177
|
+
| 0.11.0 (2021-11-17) | 1.8.2 (2021-10-18) | no |
|
178
|
+
| 0.10.0 (2021-09-07) | 1.5.0 (2020-07-20) | no |
|
data/Rakefile
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require "./lib/rdkafka"
|
5
|
+
|
6
|
+
desc 'Generate some message traffic'
|
7
|
+
task :produce_messages do
|
8
|
+
config = {:"bootstrap.servers" => "localhost:9092"}
|
9
|
+
if ENV["DEBUG"]
|
10
|
+
config[:debug] = "broker,topic,msg"
|
11
|
+
end
|
12
|
+
producer = Rdkafka::Config.new(config).producer
|
13
|
+
|
14
|
+
delivery_handles = []
|
15
|
+
100.times do |i|
|
16
|
+
puts "Producing message #{i}"
|
17
|
+
delivery_handles << producer.produce(
|
18
|
+
topic: "rake_test_topic",
|
19
|
+
payload: "Payload #{i} from Rake",
|
20
|
+
key: "Key #{i} from Rake"
|
21
|
+
)
|
22
|
+
end
|
23
|
+
puts 'Waiting for delivery'
|
24
|
+
delivery_handles.each(&:wait)
|
25
|
+
puts 'Done'
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'Consume some messages'
|
29
|
+
task :consume_messages do
|
30
|
+
config = {
|
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
|
+
}
|
37
|
+
if ENV["DEBUG"]
|
38
|
+
config[:debug] = "cgrp,topic,fetch"
|
39
|
+
end
|
40
|
+
Rdkafka::Config.statistics_callback = lambda do |stats|
|
41
|
+
puts stats
|
42
|
+
end
|
43
|
+
consumer = Rdkafka::Config.new(config).consumer
|
44
|
+
consumer = Rdkafka::Config.new(config).consumer
|
45
|
+
consumer.subscribe("rake_test_topic")
|
46
|
+
consumer.each do |message|
|
47
|
+
puts "Message received: #{message}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'Hammer down'
|
52
|
+
task :load_test do
|
53
|
+
puts "Starting load test"
|
54
|
+
|
55
|
+
config = Rdkafka::Config.new(
|
56
|
+
:"bootstrap.servers" => "localhost:9092",
|
57
|
+
:"group.id" => "load-test",
|
58
|
+
:"enable.partition.eof" => false
|
59
|
+
)
|
60
|
+
|
61
|
+
# Create a producer in a thread
|
62
|
+
Thread.new do
|
63
|
+
producer = config.producer
|
64
|
+
loop do
|
65
|
+
handles = []
|
66
|
+
1000.times do |i|
|
67
|
+
handles.push(producer.produce(
|
68
|
+
topic: "load_test_topic",
|
69
|
+
payload: "Payload #{i}",
|
70
|
+
key: "Key #{i}"
|
71
|
+
))
|
72
|
+
end
|
73
|
+
handles.each(&:wait)
|
74
|
+
puts "Produced 1000 messages"
|
75
|
+
end
|
76
|
+
end.abort_on_exception = true
|
77
|
+
|
78
|
+
# Create three consumers in threads
|
79
|
+
3.times do |i|
|
80
|
+
Thread.new do
|
81
|
+
count = 0
|
82
|
+
consumer = config.consumer
|
83
|
+
consumer.subscribe("load_test_topic")
|
84
|
+
consumer.each do |message|
|
85
|
+
count += 1
|
86
|
+
if count % 1000 == 0
|
87
|
+
puts "Received 1000 messages in thread #{i}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end.abort_on_exception = true
|
91
|
+
end
|
92
|
+
|
93
|
+
loop do
|
94
|
+
sleep 1
|
95
|
+
end
|
96
|
+
end
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
services:
|
2
|
+
kafka:
|
3
|
+
container_name: kafka
|
4
|
+
image: confluentinc/cp-kafka:8.0.0
|
5
|
+
|
6
|
+
ports:
|
7
|
+
- 9092:9092
|
8
|
+
|
9
|
+
environment:
|
10
|
+
CLUSTER_ID: kafka-docker-cluster-1
|
11
|
+
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
12
|
+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
13
|
+
KAFKA_PROCESS_ROLES: broker,controller
|
14
|
+
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
|
15
|
+
KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
|
16
|
+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
|
17
|
+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092
|
18
|
+
KAFKA_BROKER_ID: 1
|
19
|
+
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@127.0.0.1:9093
|
20
|
+
ALLOW_PLAINTEXT_LISTENER: 'yes'
|
21
|
+
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
|
22
|
+
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
|
23
|
+
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
|
24
|
+
KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: "true"
|
25
|
+
KAFKA_AUTHORIZER_CLASS_NAME: org.apache.kafka.metadata.authorizer.StandardAuthorizer
|
data/ext/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Ext
|
2
|
+
|
3
|
+
This gem depends on the `librdkafka` C library. It is downloaded, stored in
|
4
|
+
`dist/` directory, and checked into source control.
|
5
|
+
|
6
|
+
To update the `librdkafka` version follow the following steps:
|
7
|
+
|
8
|
+
* Go to https://github.com/confluentinc/librdkafka/releases to get the new
|
9
|
+
version number and asset checksum for `tar.gz`.
|
10
|
+
* Change the version in `lib/rdkafka/version.rb`
|
11
|
+
* Change the `sha256` in `lib/rdkafka/version.rb`
|
12
|
+
* Run `bundle exec rake dist:download` in the `ext` directory to download the
|
13
|
+
new release and place it in the `dist/` for you
|
14
|
+
* Run `bundle exec rake` in the `ext` directory to build the new version
|
15
|
+
* Run `docker-compose pull` in the main gem directory to ensure the docker
|
16
|
+
images used by the tests and run `docker-compose up`
|
17
|
+
* Finally, run `bundle exec rspec` in the main gem directory to execute
|
18
|
+
the test suite to detect any regressions that may have been introduced
|
19
|
+
by the update
|