karafka-rdkafka 0.13.2 → 0.13.9
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 +0 -0
- data/.github/workflows/ci.yml +9 -4
- data/.gitignore +4 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +54 -26
- data/{LICENSE → MIT-LICENSE} +2 -1
- data/README.md +19 -20
- data/certs/cert_chain.pem +21 -21
- data/docker-compose.yml +16 -15
- data/ext/README.md +1 -1
- data/ext/Rakefile +1 -1
- data/karafka-rdkafka.gemspec +2 -2
- data/lib/rdkafka/abstract_handle.rb +41 -27
- data/lib/rdkafka/admin/create_partitions_handle.rb +6 -3
- data/lib/rdkafka/admin/create_topic_handle.rb +6 -3
- data/lib/rdkafka/admin/delete_topic_handle.rb +6 -3
- data/lib/rdkafka/admin.rb +6 -7
- data/lib/rdkafka/bindings.rb +24 -6
- data/lib/rdkafka/config.rb +53 -19
- data/lib/rdkafka/consumer/headers.rb +2 -4
- data/lib/rdkafka/consumer.rb +119 -93
- data/lib/rdkafka/error.rb +60 -1
- data/lib/rdkafka/helpers/time.rb +14 -0
- data/lib/rdkafka/metadata.rb +4 -4
- data/lib/rdkafka/native_kafka.rb +6 -1
- data/lib/rdkafka/producer/delivery_handle.rb +16 -1
- data/lib/rdkafka/producer/delivery_report.rb +3 -2
- data/lib/rdkafka/producer.rb +89 -17
- data/lib/rdkafka/version.rb +3 -3
- data/lib/rdkafka.rb +10 -1
- data/renovate.json +6 -0
- data/spec/rdkafka/abstract_handle_spec.rb +0 -2
- data/spec/rdkafka/admin/create_topic_handle_spec.rb +4 -4
- data/spec/rdkafka/admin/create_topic_report_spec.rb +0 -2
- data/spec/rdkafka/admin/delete_topic_handle_spec.rb +3 -3
- 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 +8 -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 +0 -2
- data/spec/rdkafka/consumer_spec.rb +122 -38
- 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 +15 -2
- data/spec/rdkafka/producer/delivery_report_spec.rb +0 -2
- data/spec/rdkafka/producer_spec.rb +293 -1
- data/spec/spec_helper.rb +7 -1
- data.tar.gz.sig +0 -0
- metadata +31 -28
- metadata.gz.sig +0 -0
- data/certs/karafka-pro.pem +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c954a06b4461885d7648e8081d0426ebb895a82f1a27607f2224fc9e60843574
|
4
|
+
data.tar.gz: a25bf01b430920c7fd2cf22b0dd23ea1de9dd15d1b45f614025e97a3b725f8f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afe480fedbbe5dc6f055709aaf3601acb17aaaa890f1c6e7423b90263eb8fa893de0e8b9bb571e6abf1c5fc0b8df2a6be2e5de4af1de1b68414204275981246e
|
7
|
+
data.tar.gz: 7bb81ff6dcbc95b018ede8bd986eda701f1f5f3bb3985684d436a38a2173f8753b01e1642780eb9ad52a65ad02e2b3b7d656c4259758c8571ef2858822384875
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
name: ci
|
2
2
|
|
3
|
-
concurrency:
|
3
|
+
concurrency:
|
4
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
5
|
+
cancel-in-progress: true
|
4
6
|
|
5
7
|
on:
|
6
8
|
pull_request:
|
@@ -20,6 +22,7 @@ jobs:
|
|
20
22
|
fail-fast: false
|
21
23
|
matrix:
|
22
24
|
ruby:
|
25
|
+
- '3.3.0-preview2'
|
23
26
|
- '3.2'
|
24
27
|
- '3.1'
|
25
28
|
- '3.1.0'
|
@@ -27,15 +30,18 @@ jobs:
|
|
27
30
|
- '3.0.0'
|
28
31
|
- '2.7'
|
29
32
|
- '2.7.0'
|
30
|
-
- '2.6.8'
|
31
33
|
include:
|
32
34
|
- ruby: '3.2'
|
33
35
|
coverage: 'true'
|
34
36
|
steps:
|
35
|
-
- uses: actions/checkout@
|
37
|
+
- uses: actions/checkout@v4
|
36
38
|
- name: Install package dependencies
|
37
39
|
run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
|
38
40
|
|
41
|
+
- name: Start Kafka with docker-compose
|
42
|
+
run: |
|
43
|
+
docker-compose up -d || (sleep 5 && docker-compose up -d)
|
44
|
+
|
39
45
|
- name: Set up Ruby
|
40
46
|
uses: ruby/setup-ruby@v1
|
41
47
|
with:
|
@@ -47,7 +53,6 @@ jobs:
|
|
47
53
|
GITHUB_COVERAGE: ${{matrix.coverage}}
|
48
54
|
|
49
55
|
run: |
|
50
|
-
docker-compose up -d --no-recreate
|
51
56
|
bundle install --path vendor/bundle
|
52
57
|
cd ext && bundle exec rake && cd ..
|
53
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,11 +1,39 @@
|
|
1
|
-
#
|
1
|
+
# Rdkafka Changelog
|
2
|
+
|
3
|
+
## 0.13.9 (2023-11-07)
|
4
|
+
- [Enhancement] Expose alternative way of managing consumer events via a separate queue.
|
5
|
+
- [Enhancement] Allow for setting `statistics_callback` as nil to reset predefined settings configured by a different gem.
|
6
|
+
|
7
|
+
## 0.13.8 (2023-10-31)
|
8
|
+
- [Enhancement] Get consumer position (thijsc & mensfeld)
|
9
|
+
|
10
|
+
## 0.13.7 (2023-10-31)
|
11
|
+
- [Change] Drop support for Ruby 2.6 due to incompatibilities in usage of `ObjectSpace::WeakMap`
|
12
|
+
- [Fix] Fix dangling Opaque references.
|
13
|
+
|
14
|
+
## 0.13.6 (2023-10-17)
|
15
|
+
* **[Feature]** Support transactions API in the producer
|
16
|
+
* [Enhancement] Add `raise_response_error` flag to the `Rdkafka::AbstractHandle`.
|
17
|
+
* [Enhancement] Provide `#purge` to remove any outstanding requests from the producer.
|
18
|
+
* [Enhancement] 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.
|
19
|
+
|
20
|
+
## 0.13.5
|
21
|
+
* Fix DeliveryReport `create_result#error` being nil despite an error being associated with it
|
22
|
+
|
23
|
+
## 0.13.4
|
24
|
+
* Always call initial poll on librdkafka to make sure oauth bearer cb is handled pre-operations.
|
25
|
+
|
26
|
+
## 0.13.3
|
27
|
+
* Bump librdkafka to 2.2.0
|
28
|
+
|
29
|
+
## 0.13.2
|
2
30
|
* Ensure operations counter decrement is fully thread-safe
|
3
31
|
* Bump librdkafka to 2.1.1
|
4
32
|
|
5
|
-
|
33
|
+
## 0.13.1
|
6
34
|
* Add offsets_for_times method on consumer (timflapper)
|
7
35
|
|
8
|
-
|
36
|
+
## 0.13.0 (2023-07-24)
|
9
37
|
* Support cooperative sticky partition assignment in the rebalance callback (methodmissing)
|
10
38
|
* Support both string and symbol header keys (ColinDKelley)
|
11
39
|
* Handle tombstone messages properly (kgalieva)
|
@@ -26,32 +54,32 @@
|
|
26
54
|
* Retry metadta fetches on certain errors with a backoff (mensfeld)
|
27
55
|
* Do not lock access to underlying native kafka client and rely on Karafka granular locking (mensfeld)
|
28
56
|
|
29
|
-
|
57
|
+
## 0.12.3
|
30
58
|
- Include backtrace in non-raised binded errors.
|
31
59
|
- Include topic name in the delivery reports
|
32
60
|
|
33
|
-
|
61
|
+
## 0.12.2
|
34
62
|
* Increase the metadata default timeout from 250ms to 2 seconds. This should allow for working with remote clusters.
|
35
63
|
|
36
|
-
|
64
|
+
## 0.12.1
|
37
65
|
* Bumps librdkafka to 2.0.2 (lmaia)
|
38
66
|
* Add support for adding more partitions via Admin API
|
39
67
|
|
40
|
-
|
68
|
+
## 0.12.0 (2022-06-17)
|
41
69
|
* Bumps librdkafka to 1.9.0
|
42
70
|
* Fix crash on empty partition key (mensfeld)
|
43
71
|
* Pass the delivery handle to the callback (gvisokinskas)
|
44
72
|
|
45
|
-
|
73
|
+
## 0.11.0 (2021-11-17)
|
46
74
|
* Upgrade librdkafka to 1.8.2
|
47
75
|
* Bump supported minimum Ruby version to 2.6
|
48
76
|
* Better homebrew path detection
|
49
77
|
|
50
|
-
|
78
|
+
## 0.10.0 (2021-09-07)
|
51
79
|
* Upgrade librdkafka to 1.5.0
|
52
80
|
* Add error callback config
|
53
81
|
|
54
|
-
|
82
|
+
## 0.9.0 (2021-06-23)
|
55
83
|
* Fixes for Ruby 3.0
|
56
84
|
* Allow any callable object for callbacks (gremerritt)
|
57
85
|
* Reduce memory allocations in Rdkafka::Producer#produce (jturkel)
|
@@ -59,13 +87,13 @@
|
|
59
87
|
* Allow passing in topic configuration on create_topic (dezka)
|
60
88
|
* Add each_batch method to consumer (mgrosso)
|
61
89
|
|
62
|
-
|
90
|
+
## 0.8.1 (2020-12-07)
|
63
91
|
* Fix topic_flag behaviour and add tests for Metadata (geoff2k)
|
64
92
|
* Add topic admin interface (geoff2k)
|
65
93
|
* Raise an exception if @native_kafka is nil (geoff2k)
|
66
94
|
* Option to use zstd compression (jasonmartens)
|
67
95
|
|
68
|
-
|
96
|
+
## 0.8.0 (2020-06-02)
|
69
97
|
* Upgrade librdkafka to 1.4.0
|
70
98
|
* Integrate librdkafka metadata API and add partition_key (by Adithya-copart)
|
71
99
|
* Ruby 2.7 compatibility fix (by Geoff Thé)A
|
@@ -73,22 +101,22 @@
|
|
73
101
|
* Don't override CPPFLAGS and LDFLAGS if already set on Mac (by Hiroshi Hatake)
|
74
102
|
* Allow use of Rake 13.x and up (by Tomasz Pajor)
|
75
103
|
|
76
|
-
|
104
|
+
## 0.7.0 (2019-09-21)
|
77
105
|
* Bump librdkafka to 1.2.0 (by rob-as)
|
78
106
|
* Allow customizing the wait time for delivery report availability (by mensfeld)
|
79
107
|
|
80
|
-
|
108
|
+
## 0.6.0 (2019-07-23)
|
81
109
|
* Bump librdkafka to 1.1.0 (by Chris Gaffney)
|
82
110
|
* Implement seek (by breunigs)
|
83
111
|
|
84
|
-
|
112
|
+
## 0.5.0 (2019-04-11)
|
85
113
|
* Bump librdkafka to 1.0.0 (by breunigs)
|
86
114
|
* Add cluster and member information (by dmexe)
|
87
115
|
* Support message headers for consumer & producer (by dmexe)
|
88
116
|
* Add consumer rebalance listener (by dmexe)
|
89
117
|
* Implement pause/resume partitions (by dmexe)
|
90
118
|
|
91
|
-
|
119
|
+
## 0.4.2 (2019-01-12)
|
92
120
|
* Delivery callback for producer
|
93
121
|
* Document list param of commit method
|
94
122
|
* Use default Homebrew openssl location if present
|
@@ -97,10 +125,10 @@
|
|
97
125
|
* Add support for storing message offsets
|
98
126
|
* Add missing runtime dependency to rake
|
99
127
|
|
100
|
-
|
128
|
+
## 0.4.1 (2018-10-19)
|
101
129
|
* Bump librdkafka to 0.11.6
|
102
130
|
|
103
|
-
|
131
|
+
## 0.4.0 (2018-09-24)
|
104
132
|
* Improvements in librdkafka archive download
|
105
133
|
* Add global statistics callback
|
106
134
|
* Use Time for timestamps, potentially breaking change if you
|
@@ -112,34 +140,34 @@
|
|
112
140
|
* Support committing a topic partition list
|
113
141
|
* Add consumer assignment method
|
114
142
|
|
115
|
-
|
143
|
+
## 0.3.5 (2018-01-17)
|
116
144
|
* Fix crash when not waiting for delivery handles
|
117
145
|
* Run specs on Ruby 2.5
|
118
146
|
|
119
|
-
|
147
|
+
## 0.3.4 (2017-12-05)
|
120
148
|
* Bump librdkafka to 0.11.3
|
121
149
|
|
122
|
-
|
150
|
+
## 0.3.3 (2017-10-27)
|
123
151
|
* Fix bug that prevent display of `RdkafkaError` message
|
124
152
|
|
125
|
-
|
153
|
+
## 0.3.2 (2017-10-25)
|
126
154
|
* `add_topic` now supports using a partition count
|
127
155
|
* Add way to make errors clearer with an extra message
|
128
156
|
* Show topics in subscribe error message
|
129
157
|
* Show partition and topic in query watermark offsets error message
|
130
158
|
|
131
|
-
|
159
|
+
## 0.3.1 (2017-10-23)
|
132
160
|
* Bump librdkafka to 0.11.1
|
133
161
|
* Officially support ranges in `add_topic` for topic partition list.
|
134
162
|
* Add consumer lag calculator
|
135
163
|
|
136
|
-
|
164
|
+
## 0.3.0 (2017-10-17)
|
137
165
|
* Move both add topic methods to one `add_topic` in `TopicPartitionList`
|
138
166
|
* Add committed offsets to consumer
|
139
167
|
* Add query watermark offset to consumer
|
140
168
|
|
141
|
-
|
169
|
+
## 0.2.0 (2017-10-13)
|
142
170
|
* Some refactoring and add inline documentation
|
143
171
|
|
144
|
-
|
172
|
+
## 0.1.x (2017-09-10)
|
145
173
|
* 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
|
data/certs/cert_chain.pem
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
2
|
MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MRAwDgYDVQQDDAdjb250
|
3
3
|
YWN0MRcwFQYKCZImiZPyLGQBGRYHa2FyYWZrYTESMBAGCgmSJomT8ixkARkWAmlv
|
4
|
-
|
4
|
+
MB4XDTIzMDgyMTA3MjU1NFoXDTI0MDgyMDA3MjU1NFowPzEQMA4GA1UEAwwHY29u
|
5
5
|
dGFjdDEXMBUGCgmSJomT8ixkARkWB2thcmFma2ExEjAQBgoJkiaJk/IsZAEZFgJp
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
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.1
|
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
@@ -17,7 +17,7 @@ task :default => :clean do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
recipe.files << {
|
20
|
-
:url => "https://codeload.github.com/
|
20
|
+
:url => "https://codeload.github.com/confluentinc/librdkafka/tar.gz/v#{Rdkafka::LIBRDKAFKA_VERSION}",
|
21
21
|
:sha256 => Rdkafka::LIBRDKAFKA_SOURCE_SHA256
|
22
22
|
}
|
23
23
|
recipe.configure_options = ["--host=#{recipe.host}"]
|
data/karafka-rdkafka.gemspec
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('lib/rdkafka/version', __dir__)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.authors = ['Thijs Cadier']
|
7
|
-
gem.email = ["
|
7
|
+
gem.email = ["contact@karafka.io"]
|
8
8
|
gem.description = "Modern Kafka client library for Ruby based on librdkafka"
|
9
9
|
gem.summary = "The rdkafka gem is a modern Kafka client library for Ruby based on librdkafka. It wraps the production-ready C client using the ffi gem and targets Kafka 1.0+ and Ruby 2.4+."
|
10
10
|
gem.license = 'MIT'
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.name = 'karafka-rdkafka'
|
16
16
|
gem.require_paths = ['lib']
|
17
17
|
gem.version = Rdkafka::VERSION
|
18
|
-
gem.required_ruby_version = '>= 2.
|
18
|
+
gem.required_ruby_version = '>= 2.7'
|
19
19
|
gem.extensions = %w(ext/Rakefile)
|
20
20
|
gem.cert_chain = %w[certs/cert_chain.pem]
|
21
21
|
|
@@ -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,29 +41,34 @@ 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
|
51
|
+
# @param raise_response_error [Boolean] should we raise error when waiting finishes
|
37
52
|
#
|
38
|
-
# @
|
39
|
-
# @param wait_timeout [Numeric] Amount of time we should wait before we recheck if the operation has completed
|
53
|
+
# @return [Object] Operation-specific result
|
40
54
|
#
|
41
55
|
# @raise [RdkafkaError] When the operation failed
|
42
56
|
# @raise [WaitTimeoutError] When the timeout has been reached and the handle is still pending
|
43
|
-
|
44
|
-
# @return [Object] Operation-specific result
|
45
|
-
def wait(max_wait_timeout: 60, wait_timeout: 0.1)
|
57
|
+
def wait(max_wait_timeout: 60, wait_timeout: 0.1, raise_response_error: true)
|
46
58
|
timeout = if max_wait_timeout
|
47
|
-
|
59
|
+
monotonic_now + max_wait_timeout
|
48
60
|
else
|
49
61
|
nil
|
50
62
|
end
|
51
63
|
loop do
|
52
64
|
if pending?
|
53
|
-
if timeout && timeout <=
|
54
|
-
raise WaitTimeoutError.new(
|
65
|
+
if timeout && timeout <= monotonic_now
|
66
|
+
raise WaitTimeoutError.new(
|
67
|
+
"Waiting for #{operation_name} timed out after #{max_wait_timeout} seconds"
|
68
|
+
)
|
55
69
|
end
|
56
70
|
sleep wait_timeout
|
57
|
-
elsif self[:response] != 0
|
71
|
+
elsif self[:response] != 0 && raise_response_error
|
58
72
|
raise_error
|
59
73
|
else
|
60
74
|
return create_result
|
@@ -74,7 +88,7 @@ module Rdkafka
|
|
74
88
|
|
75
89
|
# Allow subclasses to override
|
76
90
|
def raise_error
|
77
|
-
|
91
|
+
RdkafkaError.validate!(self[:response])
|
78
92
|
end
|
79
93
|
|
80
94
|
# Error that is raised when waiting for the handle to complete
|
@@ -17,9 +17,12 @@ module Rdkafka
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def raise_error
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
RdkafkaError.validate!(
|
21
|
+
self[:response],
|
22
|
+
broker_message: CreatePartitionsReport.new(
|
23
|
+
self[:error_string],
|
24
|
+
self[:result_name]
|
25
|
+
).error_string
|
23
26
|
)
|
24
27
|
end
|
25
28
|
end
|
@@ -19,9 +19,12 @@ module Rdkafka
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def raise_error
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
RdkafkaError.validate!(
|
23
|
+
self[:response],
|
24
|
+
broker_message: CreateTopicReport.new(
|
25
|
+
self[:error_string],
|
26
|
+
self[:result_name]
|
27
|
+
).error_string
|
25
28
|
)
|
26
29
|
end
|
27
30
|
end
|
@@ -19,9 +19,12 @@ module Rdkafka
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def raise_error
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
RdkafkaError.validate!(
|
23
|
+
self[:response],
|
24
|
+
broker_message: DeleteTopicReport.new(
|
25
|
+
self[:error_string],
|
26
|
+
self[:result_name]
|
27
|
+
).error_string
|
25
28
|
)
|
26
29
|
end
|
27
30
|
end
|