rdkafka 0.13.1 → 0.14.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +1 -0
- data/.github/workflows/ci.yml +58 -0
- data/.gitignore +4 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +39 -24
- data/{LICENSE → MIT-LICENSE} +2 -1
- data/README.md +19 -20
- data/certs/cert_chain.pem +26 -0
- data/docker-compose.yml +16 -15
- data/ext/README.md +1 -1
- data/ext/Rakefile +26 -53
- data/lib/rdkafka/abstract_handle.rb +37 -24
- data/lib/rdkafka/admin.rb +6 -7
- data/lib/rdkafka/bindings.rb +8 -5
- data/lib/rdkafka/config.rb +30 -17
- data/lib/rdkafka/consumer/headers.rb +2 -4
- data/lib/rdkafka/consumer/topic_partition_list.rb +3 -1
- data/lib/rdkafka/consumer.rb +92 -53
- data/lib/rdkafka/helpers/time.rb +14 -0
- data/lib/rdkafka/metadata.rb +22 -1
- data/lib/rdkafka/native_kafka.rb +6 -1
- data/lib/rdkafka/producer.rb +85 -7
- data/lib/rdkafka/version.rb +3 -3
- data/lib/rdkafka.rb +10 -1
- data/rdkafka.gemspec +17 -3
- data/renovate.json +6 -0
- data/spec/rdkafka/abstract_handle_spec.rb +0 -2
- data/spec/rdkafka/admin/create_topic_handle_spec.rb +0 -2
- data/spec/rdkafka/admin/create_topic_report_spec.rb +0 -2
- data/spec/rdkafka/admin/delete_topic_handle_spec.rb +0 -2
- data/spec/rdkafka/admin/delete_topic_report_spec.rb +0 -2
- data/spec/rdkafka/admin_spec.rb +1 -2
- data/spec/rdkafka/bindings_spec.rb +0 -1
- data/spec/rdkafka/callbacks_spec.rb +0 -2
- data/spec/rdkafka/config_spec.rb +0 -2
- data/spec/rdkafka/consumer/headers_spec.rb +0 -2
- data/spec/rdkafka/consumer/message_spec.rb +0 -2
- data/spec/rdkafka/consumer/partition_spec.rb +0 -2
- data/spec/rdkafka/consumer/topic_partition_list_spec.rb +19 -2
- data/spec/rdkafka/consumer_spec.rb +143 -39
- data/spec/rdkafka/error_spec.rb +0 -2
- data/spec/rdkafka/metadata_spec.rb +2 -3
- data/spec/rdkafka/native_kafka_spec.rb +2 -3
- data/spec/rdkafka/producer/delivery_handle_spec.rb +0 -2
- data/spec/rdkafka/producer/delivery_report_spec.rb +0 -2
- data/spec/rdkafka/producer_spec.rb +157 -1
- data.tar.gz.sig +0 -0
- metadata +51 -13
- metadata.gz.sig +0 -0
- data/.semaphore/semaphore.yml +0 -27
- data/dist/librdkafka_2.0.2.tar.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e50643841e7ff26de5ee8a05339cdf92d78df620215594f4672d8fa0d03b4022
|
4
|
+
data.tar.gz: 8c95de343d98a03132a1e8646c334e54576981ba88d66d045bb39d5fff31b3c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf82c6a67542d64d915cfbb15f946107da6a63f46f0b94969d67365c95e0d026c1b4bb3d40f06cac720896b22e52b845b1ea413c7dffcf278f89f5843c15e3f8
|
7
|
+
data.tar.gz: 350b8490222dcda953c2b65543b95641d2cd566c4bf9df6616123ab57c715fb4d823f1f97702eb247c6ecc8ee9e41b45ea0cd60e7e94a5c04cf0a9dcb7b24468
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
G��TAn)wI���w)��c��>�%I�����L����^�P�l��ѯJ:����}��1�7�$��'4asA�y0e����#*ܗRL��~�c�[��I�� �rd�r�L��q��q1�ӂ'G�"��Պ�sń�II@��]Mu��w���w��@�u��"k�uBnI�R����,#/_TH����$���ݭ����K:�{���C����I�S#�:�l��n�$� ��F��>p%�#jz�=� �<�����3�?A�!�}��]B)㐗\�H����Q��*��
|
@@ -0,0 +1,58 @@
|
|
1
|
+
name: ci
|
2
|
+
|
3
|
+
concurrency:
|
4
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
5
|
+
cancel-in-progress: true
|
6
|
+
|
7
|
+
on:
|
8
|
+
pull_request:
|
9
|
+
push:
|
10
|
+
schedule:
|
11
|
+
- cron: '0 1 * * *'
|
12
|
+
|
13
|
+
env:
|
14
|
+
BUNDLE_RETRY: 6
|
15
|
+
BUNDLE_JOBS: 4
|
16
|
+
|
17
|
+
jobs:
|
18
|
+
specs:
|
19
|
+
timeout-minutes: 30
|
20
|
+
runs-on: ubuntu-latest
|
21
|
+
strategy:
|
22
|
+
fail-fast: false
|
23
|
+
matrix:
|
24
|
+
ruby:
|
25
|
+
- '3.3.0-preview2'
|
26
|
+
- '3.2'
|
27
|
+
- '3.1'
|
28
|
+
- '3.1.0'
|
29
|
+
- '3.0'
|
30
|
+
- '3.0.0'
|
31
|
+
- '2.7'
|
32
|
+
- '2.7.0'
|
33
|
+
include:
|
34
|
+
- ruby: '3.2'
|
35
|
+
coverage: 'true'
|
36
|
+
steps:
|
37
|
+
- uses: actions/checkout@v4
|
38
|
+
- name: Install package dependencies
|
39
|
+
run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
|
40
|
+
|
41
|
+
- name: Start Kafka with docker-compose
|
42
|
+
run: |
|
43
|
+
docker-compose up -d || (sleep 5 && docker-compose up -d)
|
44
|
+
|
45
|
+
- name: Set up Ruby
|
46
|
+
uses: ruby/setup-ruby@v1
|
47
|
+
with:
|
48
|
+
ruby-version: ${{matrix.ruby}}
|
49
|
+
bundler-cache: true
|
50
|
+
|
51
|
+
- name: Run all specs
|
52
|
+
env:
|
53
|
+
GITHUB_COVERAGE: ${{matrix.coverage}}
|
54
|
+
|
55
|
+
run: |
|
56
|
+
bundle install --path vendor/bundle
|
57
|
+
cd ext && bundle exec rake && cd ..
|
58
|
+
bundle exec rspec
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rdkafka-ruby
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.2
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,22 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# Rdkafka Changelog
|
2
|
+
|
3
|
+
## 0.14.0 (Unreleased)
|
4
|
+
- [Enhancement] Allow for setting `statistics_callback` as nil to reset predefined settings configured by a different gem (mensfeld)
|
5
|
+
* [Enhancement] Get consumer position (thijsc & mensfeld)
|
6
|
+
* [Enhancement] Provide `#purge` to remove any outstanding requests from the producer (mensfeld)
|
7
|
+
* [Enhancement] Update `librdkafka` to `2.2.0` (mensfeld)
|
8
|
+
* [Enhancement] Introduce producer partitions count metadata cache (mensfeld)
|
9
|
+
* [Enhancement] Increase metadata timeout request from `250 ms` to `2000 ms` default to allow for remote cluster operations via `rdkafka-ruby` (mensfeld)
|
10
|
+
* [Enhancement] Introduce `#name` for producers and consumers (mensfeld)
|
11
|
+
* [Enhancement] Include backtrace in non-raised binded errors (mensfeld)
|
12
|
+
* [Fix] Reference to Opaque is not released when Admin, Consumer or Producer is closed (mensfeld)
|
13
|
+
* [Fix] Trigger `#poll` on native kafka creation to handle oauthbearer cb (mensfeld)
|
14
|
+
* [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)
|
15
|
+
* [Change] Remove support for Ruby 2.6 due to it being EOL and WeakMap incompatibilities (mensfeld)
|
16
|
+
* [Change] Update Kafka Docker with Confluent KRaft (mensfeld)
|
17
|
+
* [Change] Update librdkafka repo reference from edenhill to confluentinc (mensfeld)
|
18
|
+
|
19
|
+
## 0.13.0 (2023-07-24)
|
5
20
|
* Support cooperative sticky partition assignment in the rebalance callback (methodmissing)
|
6
21
|
* Support both string and symbol header keys (ColinDKelley)
|
7
22
|
* Handle tombstone messages properly (kgalieva)
|
@@ -17,21 +32,21 @@
|
|
17
32
|
* Make metadata request timeout configurable (mensfeld)
|
18
33
|
* call_on_partitions_assigned and call_on_partitions_revoked only get a tpl passed in (thijsc)
|
19
34
|
|
20
|
-
|
35
|
+
## 0.12.0 (2022-06-17)
|
21
36
|
* Bumps librdkafka to 1.9.0
|
22
37
|
* Fix crash on empty partition key (mensfeld)
|
23
38
|
* Pass the delivery handle to the callback (gvisokinskas)
|
24
39
|
|
25
|
-
|
40
|
+
## 0.11.0 (2021-11-17)
|
26
41
|
* Upgrade librdkafka to 1.8.2
|
27
42
|
* Bump supported minimum Ruby version to 2.6
|
28
43
|
* Better homebrew path detection
|
29
44
|
|
30
|
-
|
45
|
+
## 0.10.0 (2021-09-07)
|
31
46
|
* Upgrade librdkafka to 1.5.0
|
32
47
|
* Add error callback config
|
33
48
|
|
34
|
-
|
49
|
+
## 0.9.0 (2021-06-23)
|
35
50
|
* Fixes for Ruby 3.0
|
36
51
|
* Allow any callable object for callbacks (gremerritt)
|
37
52
|
* Reduce memory allocations in Rdkafka::Producer#produce (jturkel)
|
@@ -39,13 +54,13 @@
|
|
39
54
|
* Allow passing in topic configuration on create_topic (dezka)
|
40
55
|
* Add each_batch method to consumer (mgrosso)
|
41
56
|
|
42
|
-
|
57
|
+
## 0.8.1 (2020-12-07)
|
43
58
|
* Fix topic_flag behaviour and add tests for Metadata (geoff2k)
|
44
59
|
* Add topic admin interface (geoff2k)
|
45
60
|
* Raise an exception if @native_kafka is nil (geoff2k)
|
46
61
|
* Option to use zstd compression (jasonmartens)
|
47
62
|
|
48
|
-
|
63
|
+
## 0.8.0 (2020-06-02)
|
49
64
|
* Upgrade librdkafka to 1.4.0
|
50
65
|
* Integrate librdkafka metadata API and add partition_key (by Adithya-copart)
|
51
66
|
* Ruby 2.7 compatibility fix (by Geoff Thé)A
|
@@ -53,22 +68,22 @@
|
|
53
68
|
* Don't override CPPFLAGS and LDFLAGS if already set on Mac (by Hiroshi Hatake)
|
54
69
|
* Allow use of Rake 13.x and up (by Tomasz Pajor)
|
55
70
|
|
56
|
-
|
71
|
+
## 0.7.0 (2019-09-21)
|
57
72
|
* Bump librdkafka to 1.2.0 (by rob-as)
|
58
73
|
* Allow customizing the wait time for delivery report availability (by mensfeld)
|
59
74
|
|
60
|
-
|
75
|
+
## 0.6.0 (2019-07-23)
|
61
76
|
* Bump librdkafka to 1.1.0 (by Chris Gaffney)
|
62
77
|
* Implement seek (by breunigs)
|
63
78
|
|
64
|
-
|
79
|
+
## 0.5.0 (2019-04-11)
|
65
80
|
* Bump librdkafka to 1.0.0 (by breunigs)
|
66
81
|
* Add cluster and member information (by dmexe)
|
67
82
|
* Support message headers for consumer & producer (by dmexe)
|
68
83
|
* Add consumer rebalance listener (by dmexe)
|
69
84
|
* Implement pause/resume partitions (by dmexe)
|
70
85
|
|
71
|
-
|
86
|
+
## 0.4.2 (2019-01-12)
|
72
87
|
* Delivery callback for producer
|
73
88
|
* Document list param of commit method
|
74
89
|
* Use default Homebrew openssl location if present
|
@@ -77,10 +92,10 @@
|
|
77
92
|
* Add support for storing message offsets
|
78
93
|
* Add missing runtime dependency to rake
|
79
94
|
|
80
|
-
|
95
|
+
## 0.4.1 (2018-10-19)
|
81
96
|
* Bump librdkafka to 0.11.6
|
82
97
|
|
83
|
-
|
98
|
+
## 0.4.0 (2018-09-24)
|
84
99
|
* Improvements in librdkafka archive download
|
85
100
|
* Add global statistics callback
|
86
101
|
* Use Time for timestamps, potentially breaking change if you
|
@@ -92,34 +107,34 @@
|
|
92
107
|
* Support committing a topic partition list
|
93
108
|
* Add consumer assignment method
|
94
109
|
|
95
|
-
|
110
|
+
## 0.3.5 (2018-01-17)
|
96
111
|
* Fix crash when not waiting for delivery handles
|
97
112
|
* Run specs on Ruby 2.5
|
98
113
|
|
99
|
-
|
114
|
+
## 0.3.4 (2017-12-05)
|
100
115
|
* Bump librdkafka to 0.11.3
|
101
116
|
|
102
|
-
|
117
|
+
## 0.3.3 (2017-10-27)
|
103
118
|
* Fix bug that prevent display of `RdkafkaError` message
|
104
119
|
|
105
|
-
|
120
|
+
## 0.3.2 (2017-10-25)
|
106
121
|
* `add_topic` now supports using a partition count
|
107
122
|
* Add way to make errors clearer with an extra message
|
108
123
|
* Show topics in subscribe error message
|
109
124
|
* Show partition and topic in query watermark offsets error message
|
110
125
|
|
111
|
-
|
126
|
+
## 0.3.1 (2017-10-23)
|
112
127
|
* Bump librdkafka to 0.11.1
|
113
128
|
* Officially support ranges in `add_topic` for topic partition list.
|
114
129
|
* Add consumer lag calculator
|
115
130
|
|
116
|
-
|
131
|
+
## 0.3.0 (2017-10-17)
|
117
132
|
* Move both add topic methods to one `add_topic` in `TopicPartitionList`
|
118
133
|
* Add committed offsets to consumer
|
119
134
|
* Add query watermark offset to consumer
|
120
135
|
|
121
|
-
|
136
|
+
## 0.2.0 (2017-10-13)
|
122
137
|
* Some refactoring and add inline documentation
|
123
138
|
|
124
|
-
|
139
|
+
## 0.1.x (2017-09-10)
|
125
140
|
* Initial working version including producing and consuming
|
data/{LICENSE → MIT-LICENSE}
RENAMED
@@ -1,6 +1,7 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2017 Thijs Cadier
|
3
|
+
Copyright (c) 2017-2023 Thijs Cadier
|
4
|
+
2023, Maciej Mensfeld
|
4
5
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,26 +1,25 @@
|
|
1
1
|
# Rdkafka
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://github.com/karafka/rdkafka-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/karafka/rdkafka-ruby/actions/workflows/ci.yml)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/rdkafka.svg)](https://badge.fury.io/rb/rdkafka)
|
5
|
-
[![
|
5
|
+
[![Join the chat at https://slack.karafka.io](https://raw.githubusercontent.com/karafka/misc/master/slack.svg)](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
|
+
---
|
6
11
|
|
7
12
|
The `rdkafka` gem is a modern Kafka client library for Ruby based on
|
8
|
-
[librdkafka](https://github.com/
|
13
|
+
[librdkafka](https://github.com/confluentinc/librdkafka/).
|
9
14
|
It wraps the production-ready C client using the [ffi](https://github.com/ffi/ffi)
|
10
|
-
gem and targets Kafka 1.0+ and Ruby versions
|
11
|
-
active maintenance. We remove Ruby version from our CI builds
|
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
|
12
17
|
become EOL.
|
13
18
|
|
14
|
-
`rdkafka` was written because
|
15
|
-
Kafka that supports modern Kafka at [AppSignal](https://appsignal.com).
|
16
|
-
We run it in production on very high traffic systems.
|
17
|
-
|
18
|
-
This gem only provides a high-level Kafka consumer. If you are running
|
19
|
-
an older version of Kafka and/or need the legacy simple consumer we
|
20
|
-
suggest using the [Hermann](https://github.com/reiseburo/hermann) gem.
|
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.
|
21
20
|
|
22
21
|
The most important pieces of a Kafka client are implemented. We're
|
23
|
-
working towards feature completeness
|
22
|
+
working towards feature completeness. You can track that here:
|
24
23
|
https://github.com/appsignal/rdkafka-ruby/milestone/1
|
25
24
|
|
26
25
|
## Table of content
|
@@ -39,7 +38,7 @@ https://github.com/appsignal/rdkafka-ruby/milestone/1
|
|
39
38
|
## Installation
|
40
39
|
|
41
40
|
This gem downloads and compiles librdkafka when it is installed. If you
|
42
|
-
have any problems installing the gem please open an issue.
|
41
|
+
If you have any problems installing the gem, please open an issue.
|
43
42
|
|
44
43
|
## Usage
|
45
44
|
|
@@ -65,9 +64,9 @@ end
|
|
65
64
|
|
66
65
|
### Producing messages
|
67
66
|
|
68
|
-
Produce a number of messages, put the delivery handles in an array and
|
67
|
+
Produce a number of messages, put the delivery handles in an array, and
|
69
68
|
wait for them before exiting. This way the messages will be batched and
|
70
|
-
sent to Kafka
|
69
|
+
efficiently sent to Kafka.
|
71
70
|
|
72
71
|
```ruby
|
73
72
|
config = {:"bootstrap.servers" => "localhost:9092"}
|
@@ -92,7 +91,7 @@ released until it `#close` is explicitly called, so be sure to call
|
|
92
91
|
|
93
92
|
## Higher level libraries
|
94
93
|
|
95
|
-
Currently, there are two actively developed frameworks based on rdkafka-ruby, that provide higher
|
94
|
+
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.
|
96
95
|
|
97
96
|
### Message processing frameworks
|
98
97
|
|
@@ -105,7 +104,7 @@ Currently, there are two actively developed frameworks based on rdkafka-ruby, th
|
|
105
104
|
|
106
105
|
## Development
|
107
106
|
|
108
|
-
A Docker Compose file is included to run Kafka
|
107
|
+
A Docker Compose file is included to run Kafka. To run
|
109
108
|
that:
|
110
109
|
|
111
110
|
```
|
@@ -123,7 +122,7 @@ DEBUG_PRODUCER=true bundle exec rspec
|
|
123
122
|
DEBUG_CONSUMER=true bundle exec rspec
|
124
123
|
```
|
125
124
|
|
126
|
-
After running the tests you can bring the cluster down to start with a
|
125
|
+
After running the tests, you can bring the cluster down to start with a
|
127
126
|
clean slate:
|
128
127
|
|
129
128
|
```
|
@@ -132,7 +131,7 @@ docker-compose down
|
|
132
131
|
|
133
132
|
## Example
|
134
133
|
|
135
|
-
To see everything working run these in separate tabs:
|
134
|
+
To see everything working, run these in separate tabs:
|
136
135
|
|
137
136
|
```
|
138
137
|
bundle exec rake consume_messages
|
@@ -0,0 +1,26 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MRAwDgYDVQQDDAdjb250
|
3
|
+
YWN0MRcwFQYKCZImiZPyLGQBGRYHa2FyYWZrYTESMBAGCgmSJomT8ixkARkWAmlv
|
4
|
+
MB4XDTIzMDgyMTA3MjU1NFoXDTI0MDgyMDA3MjU1NFowPzEQMA4GA1UEAwwHY29u
|
5
|
+
dGFjdDEXMBUGCgmSJomT8ixkARkWB2thcmFma2ExEjAQBgoJkiaJk/IsZAEZFgJp
|
6
|
+
bzCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAOuZpyQKEwsTG9plLat7
|
7
|
+
8bUaNuNBEnouTsNMr6X+XTgvyrAxTuocdsyP1sNCjdS1B8RiiDH1/Nt9qpvlBWon
|
8
|
+
sdJ1SYhaWNVfqiYStTDnCx3PRMmHRdD4KqUWKpN6VpZ1O/Zu+9Mw0COmvXgZuuO9
|
9
|
+
wMSJkXRo6dTCfMedLAIxjMeBIxtoLR2e6Jm6MR8+8WYYVWrO9kSOOt5eKQLBY7aK
|
10
|
+
b/Dc40EcJKPg3Z30Pia1M9ZyRlb6SOj6SKpHRqc7vbVQxjEw6Jjal1lZ49m3YZMd
|
11
|
+
ArMAs9lQZNdSw5/UX6HWWURLowg6k10RnhTUtYyzO9BFev0JFJftHnmuk8vtb+SD
|
12
|
+
5VPmjFXg2VOcw0B7FtG75Vackk8QKfgVe3nSPhVpew2CSPlbJzH80wChbr19+e3+
|
13
|
+
YGr1tOiaJrL6c+PNmb0F31NXMKpj/r+n15HwlTMRxQrzFcgjBlxf2XFGnPQXHhBm
|
14
|
+
kp1OFnEq4GG9sON4glRldkwzi/f/fGcZmo5fm3d+0ZdNgwIDAQABo3cwdTAJBgNV
|
15
|
+
HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUPVH5+dLA80A1kJ2Uz5iGwfOa
|
16
|
+
1+swHQYDVR0RBBYwFIESY29udGFjdEBrYXJhZmthLmlvMB0GA1UdEgQWMBSBEmNv
|
17
|
+
bnRhY3RAa2FyYWZrYS5pbzANBgkqhkiG9w0BAQsFAAOCAYEAnpa0jcN7JzREHMTQ
|
18
|
+
bfZ+xcvlrzuROMY6A3zIZmQgbnoZZNuX4cMRrT1p1HuwXpxdpHPw7dDjYqWw3+1h
|
19
|
+
3mXLeMuk7amjQpYoSWU/OIZMhIsARra22UN8qkkUlUj3AwTaChVKN/bPJOM2DzfU
|
20
|
+
kz9vUgLeYYFfQbZqeI6SsM7ltilRV4W8D9yNUQQvOxCFxtLOetJ00fC/E7zMUzbK
|
21
|
+
IBwYFQYsbI6XQzgAIPW6nGSYKgRhkfpmquXSNKZRIQ4V6bFrufa+DzD0bt2ZA3ah
|
22
|
+
fMmJguyb5L2Gf1zpDXzFSPMG7YQFLzwYz1zZZvOU7/UCpQsHpID/YxqDp4+Dgb+Y
|
23
|
+
qma0whX8UG/gXFV2pYWpYOfpatvahwi+A1TwPQsuZwkkhi1OyF1At3RY+hjSXyav
|
24
|
+
AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
|
25
|
+
msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
|
26
|
+
-----END CERTIFICATE-----
|
data/docker-compose.yml
CHANGED
@@ -1,24 +1,25 @@
|
|
1
|
-
---
|
2
|
-
|
3
1
|
version: '2'
|
4
2
|
|
5
3
|
services:
|
6
|
-
zookeeper:
|
7
|
-
image: confluentinc/cp-zookeeper:5.2.6
|
8
|
-
environment:
|
9
|
-
ZOOKEEPER_CLIENT_PORT: 2181
|
10
|
-
ZOOKEEPER_TICK_TIME: 2000
|
11
|
-
|
12
4
|
kafka:
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
container_name: kafka
|
6
|
+
image: confluentinc/cp-kafka:7.5.2
|
7
|
+
|
16
8
|
ports:
|
17
9
|
- 9092:9092
|
10
|
+
|
18
11
|
environment:
|
19
|
-
|
20
|
-
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
21
|
-
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:29092,PLAINTEXT_HOST://localhost:9092
|
22
|
-
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
|
12
|
+
CLUSTER_ID: kafka-docker-cluster-1
|
23
13
|
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
24
14
|
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
15
|
+
KAFKA_PROCESS_ROLES: broker,controller
|
16
|
+
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
|
17
|
+
KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
|
18
|
+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
|
19
|
+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092
|
20
|
+
KAFKA_BROKER_ID: 1
|
21
|
+
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@127.0.0.1:9093
|
22
|
+
ALLOW_PLAINTEXT_LISTENER: 'yes'
|
23
|
+
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
|
24
|
+
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
|
25
|
+
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
|
data/ext/README.md
CHANGED
@@ -5,7 +5,7 @@ this gem is installed.
|
|
5
5
|
|
6
6
|
To update the `librdkafka` version follow the following steps:
|
7
7
|
|
8
|
-
* Go to https://github.com/
|
8
|
+
* Go to https://github.com/confluentinc/librdkafka/releases to get the new
|
9
9
|
version number and asset checksum for `tar.gz`.
|
10
10
|
* Change the version in `lib/rdkafka/version.rb`
|
11
11
|
* Change the `sha256` in `lib/rdkafka/version.rb`
|
data/ext/Rakefile
CHANGED
@@ -1,67 +1,40 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require File.expand_path('../../lib/rdkafka/version', __FILE__)
|
4
|
+
require "mini_portile2"
|
4
5
|
require "fileutils"
|
5
6
|
require "open-uri"
|
6
7
|
|
7
8
|
task :default => :clean do
|
8
|
-
#
|
9
|
-
|
10
|
-
#
|
11
|
-
# Mini_portile causes an issue because it's dependencies are downloaded on the fly and therefore don't exist/aren't
|
12
|
-
# accessible in the nix environment
|
13
|
-
if ENV.fetch('RDKAFKA_EXT_PATH', '').empty?
|
14
|
-
# Download and compile librdkafka if RDKAFKA_EXT_PATH is not set
|
15
|
-
require "mini_portile2"
|
16
|
-
recipe = MiniPortile.new("librdkafka", Rdkafka::LIBRDKAFKA_VERSION)
|
9
|
+
# Download and compile librdkafka
|
10
|
+
recipe = MiniPortile.new("librdkafka", Rdkafka::LIBRDKAFKA_VERSION)
|
17
11
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
releases = File.expand_path(File.join(File.dirname(__FILE__), '../dist'))
|
26
|
-
|
27
|
-
recipe.files << {
|
28
|
-
:url => "file://#{releases}/librdkafka_#{Rdkafka::LIBRDKAFKA_VERSION}.tar.gz",
|
29
|
-
:sha256 => Rdkafka::LIBRDKAFKA_SOURCE_SHA256
|
30
|
-
}
|
31
|
-
recipe.configure_options = ["--host=#{recipe.host}"]
|
32
|
-
|
33
|
-
# Disable using libc regex engine in favor of the embedded one
|
34
|
-
# The default regex engine of librdkafka does not always work exactly as most of the users
|
35
|
-
# would expect, hence this flag allows for changing it to the other one
|
36
|
-
if ENV.key?('RDKAFKA_DISABLE_REGEX_EXT')
|
37
|
-
recipe.configure_options << '--disable-regex-ext'
|
38
|
-
end
|
12
|
+
# Use default homebrew openssl if we're on mac and the directory exists
|
13
|
+
# and each of flags is not empty
|
14
|
+
if recipe.host&.include?("darwin") && system("which brew &> /dev/null") && Dir.exist?("#{homebrew_prefix = %x(brew --prefix openssl).strip}")
|
15
|
+
ENV["CPPFLAGS"] = "-I#{homebrew_prefix}/include" unless ENV["CPPFLAGS"]
|
16
|
+
ENV["LDFLAGS"] = "-L#{homebrew_prefix}/lib" unless ENV["LDFLAGS"]
|
17
|
+
end
|
39
18
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
FileUtils.mv(lib_path, File.join(File.dirname(__FILE__), "librdkafka.#{to_extension}"))
|
51
|
-
# Cleanup files created by miniportile we don't need in the gem
|
52
|
-
FileUtils.rm_rf File.join(File.dirname(__FILE__), "tmp")
|
53
|
-
FileUtils.rm_rf File.join(File.dirname(__FILE__), "ports")
|
19
|
+
recipe.files << {
|
20
|
+
:url => "https://codeload.github.com/confluentinc/librdkafka/tar.gz/v#{Rdkafka::LIBRDKAFKA_VERSION}",
|
21
|
+
:sha256 => Rdkafka::LIBRDKAFKA_SOURCE_SHA256
|
22
|
+
}
|
23
|
+
recipe.configure_options = ["--host=#{recipe.host}"]
|
24
|
+
recipe.cook
|
25
|
+
# Move dynamic library we're interested in
|
26
|
+
if recipe.host.include?('darwin')
|
27
|
+
from_extension = '1.dylib'
|
28
|
+
to_extension = 'dylib'
|
54
29
|
else
|
55
|
-
|
56
|
-
|
57
|
-
raise "RDKAFKA_EXT_PATH must be set in your nix config when running under nix"
|
58
|
-
end
|
59
|
-
files = [
|
60
|
-
File.join(ENV['RDKAFKA_EXT_PATH'], 'lib', 'librdkafka.dylib'),
|
61
|
-
File.join(ENV['RDKAFKA_EXT_PATH'], 'lib', 'librdkafka.so')
|
62
|
-
]
|
63
|
-
files.each { |ext| FileUtils.cp(ext, File.dirname(__FILE__)) if File.exist?(ext) }
|
30
|
+
from_extension = 'so.1'
|
31
|
+
to_extension = 'so'
|
64
32
|
end
|
33
|
+
lib_path = File.join(File.dirname(__FILE__), "ports/#{recipe.host}/librdkafka/#{Rdkafka::LIBRDKAFKA_VERSION}/lib/librdkafka.#{from_extension}")
|
34
|
+
FileUtils.mv(lib_path, File.join(File.dirname(__FILE__), "librdkafka.#{to_extension}"))
|
35
|
+
# Cleanup files created by miniportile we don't need in the gem
|
36
|
+
FileUtils.rm_rf File.join(File.dirname(__FILE__), "tmp")
|
37
|
+
FileUtils.rm_rf File.join(File.dirname(__FILE__), "ports")
|
65
38
|
end
|
66
39
|
|
67
40
|
task :clean do
|
@@ -1,28 +1,37 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "ffi"
|
4
|
-
|
5
3
|
module Rdkafka
|
4
|
+
# This class serves as an abstract base class to represent handles within the Rdkafka module.
|
5
|
+
# As a subclass of `FFI::Struct`, this class provides a blueprint for other specific handle
|
6
|
+
# classes to inherit from, ensuring they adhere to a particular structure and behavior.
|
7
|
+
#
|
8
|
+
# Subclasses must define their own layout, and the layout must start with:
|
9
|
+
#
|
10
|
+
# layout :pending, :bool,
|
11
|
+
# :response, :int
|
6
12
|
class AbstractHandle < FFI::Struct
|
7
|
-
|
8
|
-
#
|
9
|
-
# layout :pending, :bool,
|
10
|
-
# :response, :int
|
13
|
+
include Helpers::Time
|
11
14
|
|
15
|
+
# Registry for registering all the handles.
|
12
16
|
REGISTRY = {}
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
18
|
+
class << self
|
19
|
+
# Adds handle to the register
|
20
|
+
#
|
21
|
+
# @param handle [AbstractHandle] any handle we want to register
|
22
|
+
def register(handle)
|
23
|
+
address = handle.to_ptr.address
|
24
|
+
REGISTRY[address] = handle
|
25
|
+
end
|
17
26
|
|
18
|
-
|
19
|
-
|
20
|
-
|
27
|
+
# Removes handle from the register based on the handle address
|
28
|
+
#
|
29
|
+
# @param address [Integer] address of the registered handle we want to remove
|
30
|
+
def remove(address)
|
31
|
+
REGISTRY.delete(address)
|
32
|
+
end
|
21
33
|
end
|
22
34
|
|
23
|
-
def self.remove(address)
|
24
|
-
REGISTRY.delete(address)
|
25
|
-
end
|
26
35
|
|
27
36
|
# Whether the handle is still pending.
|
28
37
|
#
|
@@ -32,26 +41,30 @@ module Rdkafka
|
|
32
41
|
end
|
33
42
|
|
34
43
|
# Wait for the operation to complete or raise an error if this takes longer than the timeout.
|
35
|
-
# If there is a timeout this does not mean the operation failed, rdkafka might still be working
|
36
|
-
# In this case it is possible to call wait again.
|
44
|
+
# If there is a timeout this does not mean the operation failed, rdkafka might still be working
|
45
|
+
# on the operation. In this case it is possible to call wait again.
|
46
|
+
#
|
47
|
+
# @param max_wait_timeout [Numeric, nil] Amount of time to wait before timing out.
|
48
|
+
# If this is nil it does not time out.
|
49
|
+
# @param wait_timeout [Numeric] Amount of time we should wait before we recheck if the
|
50
|
+
# operation has completed
|
37
51
|
#
|
38
|
-
# @
|
39
|
-
# @param wait_timeout [Numeric] Amount of time we should wait before we recheck if the operation has completed
|
52
|
+
# @return [Object] Operation-specific result
|
40
53
|
#
|
41
54
|
# @raise [RdkafkaError] When the operation failed
|
42
55
|
# @raise [WaitTimeoutError] When the timeout has been reached and the handle is still pending
|
43
|
-
#
|
44
|
-
# @return [Object] Operation-specific result
|
45
56
|
def wait(max_wait_timeout: 60, wait_timeout: 0.1)
|
46
57
|
timeout = if max_wait_timeout
|
47
|
-
|
58
|
+
monotonic_now + max_wait_timeout
|
48
59
|
else
|
49
60
|
nil
|
50
61
|
end
|
51
62
|
loop do
|
52
63
|
if pending?
|
53
|
-
if timeout && timeout <=
|
54
|
-
raise WaitTimeoutError.new(
|
64
|
+
if timeout && timeout <= monotonic_now
|
65
|
+
raise WaitTimeoutError.new(
|
66
|
+
"Waiting for #{operation_name} timed out after #{max_wait_timeout} seconds"
|
67
|
+
)
|
55
68
|
end
|
56
69
|
sleep wait_timeout
|
57
70
|
elsif self[:response] != 0
|
data/lib/rdkafka/admin.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "objspace"
|
4
|
-
|
5
3
|
module Rdkafka
|
6
4
|
class Admin
|
7
5
|
# @private
|
@@ -30,11 +28,12 @@ module Rdkafka
|
|
30
28
|
|
31
29
|
# Create a topic with the given partition count and replication factor
|
32
30
|
#
|
31
|
+
# @return [CreateTopicHandle] Create topic handle that can be used to wait for the result of
|
32
|
+
# creating the topic
|
33
|
+
#
|
33
34
|
# @raise [ConfigError] When the partition count or replication factor are out of valid range
|
34
35
|
# @raise [RdkafkaError] When the topic name is invalid or the topic already exists
|
35
36
|
# @raise [RdkafkaError] When the topic configuration is invalid
|
36
|
-
#
|
37
|
-
# @return [CreateTopicHandle] Create topic handle that can be used to wait for the result of creating the topic
|
38
37
|
def create_topic(topic_name, partition_count, replication_factor, topic_config={})
|
39
38
|
closed_admin_check(__method__)
|
40
39
|
|
@@ -107,11 +106,11 @@ module Rdkafka
|
|
107
106
|
create_topic_handle
|
108
107
|
end
|
109
108
|
|
110
|
-
#
|
109
|
+
# Deletes the named topic
|
111
110
|
#
|
111
|
+
# @return [DeleteTopicHandle] Delete topic handle that can be used to wait for the result of
|
112
|
+
# deleting the topic
|
112
113
|
# @raise [RdkafkaError] When the topic name is invalid or the topic does not exist
|
113
|
-
#
|
114
|
-
# @return [DeleteTopicHandle] Delete topic handle that can be used to wait for the result of deleting the topic
|
115
114
|
def delete_topic(topic_name)
|
116
115
|
closed_admin_check(__method__)
|
117
116
|
|