rdkafka 0.13.0 → 0.14.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +1 -0
  3. data/.github/workflows/ci.yml +58 -0
  4. data/.gitignore +4 -0
  5. data/.rspec +1 -0
  6. data/.ruby-gemset +1 -0
  7. data/.ruby-version +1 -0
  8. data/CHANGELOG.md +39 -21
  9. data/{LICENSE → MIT-LICENSE} +2 -1
  10. data/README.md +19 -20
  11. data/certs/cert_chain.pem +26 -0
  12. data/docker-compose.yml +16 -15
  13. data/ext/README.md +1 -1
  14. data/ext/Rakefile +1 -1
  15. data/lib/rdkafka/abstract_handle.rb +37 -24
  16. data/lib/rdkafka/admin.rb +6 -7
  17. data/lib/rdkafka/bindings.rb +8 -5
  18. data/lib/rdkafka/config.rb +30 -17
  19. data/lib/rdkafka/consumer/headers.rb +2 -4
  20. data/lib/rdkafka/consumer/topic_partition_list.rb +3 -1
  21. data/lib/rdkafka/consumer.rb +92 -53
  22. data/lib/rdkafka/helpers/time.rb +14 -0
  23. data/lib/rdkafka/metadata.rb +22 -1
  24. data/lib/rdkafka/native_kafka.rb +6 -1
  25. data/lib/rdkafka/producer.rb +85 -7
  26. data/lib/rdkafka/version.rb +3 -3
  27. data/lib/rdkafka.rb +10 -1
  28. data/rdkafka.gemspec +17 -3
  29. data/renovate.json +6 -0
  30. data/spec/rdkafka/abstract_handle_spec.rb +0 -2
  31. data/spec/rdkafka/admin/create_topic_handle_spec.rb +0 -2
  32. data/spec/rdkafka/admin/create_topic_report_spec.rb +0 -2
  33. data/spec/rdkafka/admin/delete_topic_handle_spec.rb +0 -2
  34. data/spec/rdkafka/admin/delete_topic_report_spec.rb +0 -2
  35. data/spec/rdkafka/admin_spec.rb +1 -2
  36. data/spec/rdkafka/bindings_spec.rb +0 -1
  37. data/spec/rdkafka/callbacks_spec.rb +0 -2
  38. data/spec/rdkafka/config_spec.rb +0 -2
  39. data/spec/rdkafka/consumer/headers_spec.rb +0 -2
  40. data/spec/rdkafka/consumer/message_spec.rb +0 -2
  41. data/spec/rdkafka/consumer/partition_spec.rb +0 -2
  42. data/spec/rdkafka/consumer/topic_partition_list_spec.rb +19 -2
  43. data/spec/rdkafka/consumer_spec.rb +143 -39
  44. data/spec/rdkafka/error_spec.rb +0 -2
  45. data/spec/rdkafka/metadata_spec.rb +2 -3
  46. data/spec/rdkafka/native_kafka_spec.rb +2 -3
  47. data/spec/rdkafka/producer/delivery_handle_spec.rb +0 -2
  48. data/spec/rdkafka/producer/delivery_report_spec.rb +0 -2
  49. data/spec/rdkafka/producer_spec.rb +157 -1
  50. data.tar.gz.sig +0 -0
  51. metadata +54 -15
  52. metadata.gz.sig +0 -0
  53. data/.semaphore/semaphore.yml +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4b1881445c53cdd213efd2e7ed3feb94a32a327fdf63ab35455d337f09e7320
4
- data.tar.gz: 02276df9702539c951ab392b4c5e086f87b731f7d319aedafb7b1209bc444688
3
+ metadata.gz: e50643841e7ff26de5ee8a05339cdf92d78df620215594f4672d8fa0d03b4022
4
+ data.tar.gz: 8c95de343d98a03132a1e8646c334e54576981ba88d66d045bb39d5fff31b3c5
5
5
  SHA512:
6
- metadata.gz: 7f0e11a17d03091c8e13308c6998131c142349ce520473de7fec5908f0bcf2dfd59542966c3a850008f0db39e96b763b66f7b937487ba11f2fbb444e00aff25c
7
- data.tar.gz: d15c5f7cd5f4b9041da55e7e46bf05936c627517d5067a9449844e2721e752de852006f432e5fbe72549d77d8378545a671a969652b4abada8aa8182f4fa4985
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
@@ -1,3 +1,6 @@
1
+ # Ignore bundler config.
2
+ /.bundle
3
+
1
4
  Gemfile.lock
2
5
  ext/ports
3
6
  ext/tmp
@@ -6,3 +9,4 @@ ext/librdkafka.*
6
9
  .yardoc
7
10
  doc
8
11
  coverage
12
+ vendor
data/.rspec CHANGED
@@ -1 +1,2 @@
1
+ --require spec_helper
1
2
  --format documentation
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,4 +1,22 @@
1
- # 0.13.0
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)
2
20
  * Support cooperative sticky partition assignment in the rebalance callback (methodmissing)
3
21
  * Support both string and symbol header keys (ColinDKelley)
4
22
  * Handle tombstone messages properly (kgalieva)
@@ -14,21 +32,21 @@
14
32
  * Make metadata request timeout configurable (mensfeld)
15
33
  * call_on_partitions_assigned and call_on_partitions_revoked only get a tpl passed in (thijsc)
16
34
 
17
- # 0.12.0
35
+ ## 0.12.0 (2022-06-17)
18
36
  * Bumps librdkafka to 1.9.0
19
37
  * Fix crash on empty partition key (mensfeld)
20
38
  * Pass the delivery handle to the callback (gvisokinskas)
21
39
 
22
- # 0.11.0
40
+ ## 0.11.0 (2021-11-17)
23
41
  * Upgrade librdkafka to 1.8.2
24
42
  * Bump supported minimum Ruby version to 2.6
25
43
  * Better homebrew path detection
26
44
 
27
- # 0.10.0
45
+ ## 0.10.0 (2021-09-07)
28
46
  * Upgrade librdkafka to 1.5.0
29
47
  * Add error callback config
30
48
 
31
- # 0.9.0
49
+ ## 0.9.0 (2021-06-23)
32
50
  * Fixes for Ruby 3.0
33
51
  * Allow any callable object for callbacks (gremerritt)
34
52
  * Reduce memory allocations in Rdkafka::Producer#produce (jturkel)
@@ -36,13 +54,13 @@
36
54
  * Allow passing in topic configuration on create_topic (dezka)
37
55
  * Add each_batch method to consumer (mgrosso)
38
56
 
39
- # 0.8.1
57
+ ## 0.8.1 (2020-12-07)
40
58
  * Fix topic_flag behaviour and add tests for Metadata (geoff2k)
41
59
  * Add topic admin interface (geoff2k)
42
60
  * Raise an exception if @native_kafka is nil (geoff2k)
43
61
  * Option to use zstd compression (jasonmartens)
44
62
 
45
- # 0.8.0
63
+ ## 0.8.0 (2020-06-02)
46
64
  * Upgrade librdkafka to 1.4.0
47
65
  * Integrate librdkafka metadata API and add partition_key (by Adithya-copart)
48
66
  * Ruby 2.7 compatibility fix (by Geoff Thé)A
@@ -50,22 +68,22 @@
50
68
  * Don't override CPPFLAGS and LDFLAGS if already set on Mac (by Hiroshi Hatake)
51
69
  * Allow use of Rake 13.x and up (by Tomasz Pajor)
52
70
 
53
- # 0.7.0
71
+ ## 0.7.0 (2019-09-21)
54
72
  * Bump librdkafka to 1.2.0 (by rob-as)
55
73
  * Allow customizing the wait time for delivery report availability (by mensfeld)
56
74
 
57
- # 0.6.0
75
+ ## 0.6.0 (2019-07-23)
58
76
  * Bump librdkafka to 1.1.0 (by Chris Gaffney)
59
77
  * Implement seek (by breunigs)
60
78
 
61
- # 0.5.0
79
+ ## 0.5.0 (2019-04-11)
62
80
  * Bump librdkafka to 1.0.0 (by breunigs)
63
81
  * Add cluster and member information (by dmexe)
64
82
  * Support message headers for consumer & producer (by dmexe)
65
83
  * Add consumer rebalance listener (by dmexe)
66
84
  * Implement pause/resume partitions (by dmexe)
67
85
 
68
- # 0.4.2
86
+ ## 0.4.2 (2019-01-12)
69
87
  * Delivery callback for producer
70
88
  * Document list param of commit method
71
89
  * Use default Homebrew openssl location if present
@@ -74,10 +92,10 @@
74
92
  * Add support for storing message offsets
75
93
  * Add missing runtime dependency to rake
76
94
 
77
- # 0.4.1
95
+ ## 0.4.1 (2018-10-19)
78
96
  * Bump librdkafka to 0.11.6
79
97
 
80
- # 0.4.0
98
+ ## 0.4.0 (2018-09-24)
81
99
  * Improvements in librdkafka archive download
82
100
  * Add global statistics callback
83
101
  * Use Time for timestamps, potentially breaking change if you
@@ -89,34 +107,34 @@
89
107
  * Support committing a topic partition list
90
108
  * Add consumer assignment method
91
109
 
92
- # 0.3.5
110
+ ## 0.3.5 (2018-01-17)
93
111
  * Fix crash when not waiting for delivery handles
94
112
  * Run specs on Ruby 2.5
95
113
 
96
- # 0.3.4
114
+ ## 0.3.4 (2017-12-05)
97
115
  * Bump librdkafka to 0.11.3
98
116
 
99
- # 0.3.3
117
+ ## 0.3.3 (2017-10-27)
100
118
  * Fix bug that prevent display of `RdkafkaError` message
101
119
 
102
- # 0.3.2
120
+ ## 0.3.2 (2017-10-25)
103
121
  * `add_topic` now supports using a partition count
104
122
  * Add way to make errors clearer with an extra message
105
123
  * Show topics in subscribe error message
106
124
  * Show partition and topic in query watermark offsets error message
107
125
 
108
- # 0.3.1
126
+ ## 0.3.1 (2017-10-23)
109
127
  * Bump librdkafka to 0.11.1
110
128
  * Officially support ranges in `add_topic` for topic partition list.
111
129
  * Add consumer lag calculator
112
130
 
113
- # 0.3.0
131
+ ## 0.3.0 (2017-10-17)
114
132
  * Move both add topic methods to one `add_topic` in `TopicPartitionList`
115
133
  * Add committed offsets to consumer
116
134
  * Add query watermark offset to consumer
117
135
 
118
- # 0.2.0
136
+ ## 0.2.0 (2017-10-13)
119
137
  * Some refactoring and add inline documentation
120
138
 
121
- # 0.1.x
139
+ ## 0.1.x (2017-09-10)
122
140
  * Initial working version including producing and consuming
@@ -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://appsignal.semaphoreci.com/badges/rdkafka-ruby/branches/master.svg?style=shields)](https://appsignal.semaphoreci.com/projects/rdkafka-ruby)
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
- [![Maintainability](https://api.codeclimate.com/v1/badges/ecb1765f81571cccdb0e/maintainability)](https://codeclimate.com/github/appsignal/rdkafka-ruby/maintainability)
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/edenhill/librdkafka/).
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 that are under security or
11
- active maintenance. We remove Ruby version from our CI builds if they
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 we needed a reliable Ruby client for
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, you can track that here:
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 in an efficient way.
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 level API that can be used to work with Kafka messages and one library for publishing messages.
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 and Zookeeper. To run
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
- image: confluentinc/cp-kafka:5.2.5-10
14
- depends_on:
15
- - zookeeper
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
- KAFKA_BROKER_ID: 1
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/edenhill/librdkafka/releases to get the new
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/edenhill/librdkafka/tar.gz/v#{Rdkafka::LIBRDKAFKA_VERSION}",
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}"]
@@ -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
- # Subclasses must define their own layout, and the layout must start with:
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
- CURRENT_TIME = -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) }.freeze
15
-
16
- private_constant :CURRENT_TIME
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
- def self.register(handle)
19
- address = handle.to_ptr.address
20
- REGISTRY[address] = handle
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 on the operation.
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
- # @param max_wait_timeout [Numeric, nil] Amount of time to wait before timing out. If this is nil it does not time out.
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
- CURRENT_TIME.call + max_wait_timeout
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 <= CURRENT_TIME.call
54
- raise WaitTimeoutError.new("Waiting for #{operation_name} timed out after #{max_wait_timeout} seconds")
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
- # Delete the named topic
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
 
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "ffi"
4
- require "json"
5
- require "logger"
6
-
7
3
  module Rdkafka
8
4
  # @private
9
5
  module Bindings
@@ -35,12 +31,13 @@ module Rdkafka
35
31
 
36
32
  # Polling
37
33
 
38
- attach_function :rd_kafka_flush, [:pointer, :int], :void, blocking: true
34
+ attach_function :rd_kafka_flush, [:pointer, :int], :int, blocking: true
39
35
  attach_function :rd_kafka_poll, [:pointer, :int], :void, blocking: true
40
36
  attach_function :rd_kafka_outq_len, [:pointer], :int, blocking: true
41
37
 
42
38
  # Metadata
43
39
 
40
+ attach_function :rd_kafka_name, [:pointer], :string, blocking: true
44
41
  attach_function :rd_kafka_memberid, [:pointer], :string, blocking: true
45
42
  attach_function :rd_kafka_clusterid, [:pointer], :string, blocking: true
46
43
  attach_function :rd_kafka_metadata, [:pointer, :int, :pointer, :pointer, :int], :int, blocking: true
@@ -157,6 +154,7 @@ module Rdkafka
157
154
  ) do |_client_prr, err_code, reason, _opaque|
158
155
  if Rdkafka::Config.error_callback
159
156
  error = Rdkafka::RdkafkaError.new(err_code, broker_message: reason)
157
+ error.set_backtrace(caller)
160
158
  Rdkafka::Config.error_callback.call(error)
161
159
  end
162
160
  end
@@ -190,6 +188,8 @@ module Rdkafka
190
188
  attach_function :rd_kafka_pause_partitions, [:pointer, :pointer], :int, blocking: true
191
189
  attach_function :rd_kafka_resume_partitions, [:pointer, :pointer], :int, blocking: true
192
190
  attach_function :rd_kafka_seek, [:pointer, :int32, :int64, :int], :int, blocking: true
191
+ attach_function :rd_kafka_offsets_for_times, [:pointer, :pointer, :int], :int, blocking: true
192
+ attach_function :rd_kafka_position, [:pointer, :pointer], :int, blocking: true
193
193
 
194
194
  # Headers
195
195
  attach_function :rd_kafka_header_get_all, [:pointer, :size_t, :pointer, :pointer, SizePtr], :int
@@ -251,10 +251,13 @@ module Rdkafka
251
251
  RD_KAFKA_VTYPE_TIMESTAMP = 8
252
252
  RD_KAFKA_VTYPE_HEADER = 9
253
253
  RD_KAFKA_VTYPE_HEADERS = 10
254
+ RD_KAFKA_PURGE_F_QUEUE = 1
255
+ RD_KAFKA_PURGE_F_INFLIGHT = 2
254
256
 
255
257
  RD_KAFKA_MSG_F_COPY = 0x2
256
258
 
257
259
  attach_function :rd_kafka_producev, [:pointer, :varargs], :int, blocking: true
260
+ attach_function :rd_kafka_purge, [:pointer, :int], :int, blocking: true
258
261
  callback :delivery_cb, [:pointer, :pointer, :pointer], :void
259
262
  attach_function :rd_kafka_conf_set_dr_msg_cb, [:pointer, :delivery_cb], :void
260
263