karafka-rdkafka 0.13.6 → 0.13.7
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 +4 -3
- data/CHANGELOG.md +4 -0
- data/README.md +8 -9
- data/docker-compose.yml +1 -1
- data/karafka-rdkafka.gemspec +2 -2
- data/lib/rdkafka/config.rb +23 -4
- data/lib/rdkafka/native_kafka.rb +3 -1
- data/lib/rdkafka/version.rb +1 -1
- data/renovate.json +6 -0
- data/spec/rdkafka/native_kafka_spec.rb +2 -1
- data/spec/rdkafka/producer_spec.rb +9 -3
- data/spec/spec_helper.rb +4 -0
- data.tar.gz.sig +0 -0
- metadata +5 -5
- 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: 4fe6b47d334265ef793c32b215dca1d97adfa42a51215b9492f1d36b58a84403
|
4
|
+
data.tar.gz: 4fc125147d796f981314640779adf5234376b0d0357c0321683002820fcb3301
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7fc5d7dc99653f117b4bef3baa0d6e772537f4a7df6375a6a33692d4a9728f81308e11c3cd873fbb5686fb83cf2021a5866eb252e10661b3fe512639e3e3349
|
7
|
+
data.tar.gz: 9d23217c18093187f1fecc5afbbdbe05d2a6be3cb99adb0dc20ed7458da19c7035cc51eda664e09c3acaa5ac3dd3539b0c58c91cd6d6faed3c1d21edc9662dde
|
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:
|
@@ -28,12 +30,11 @@ jobs:
|
|
28
30
|
- '3.0.0'
|
29
31
|
- '2.7'
|
30
32
|
- '2.7.0'
|
31
|
-
- '2.6.8'
|
32
33
|
include:
|
33
34
|
- ruby: '3.2'
|
34
35
|
coverage: 'true'
|
35
36
|
steps:
|
36
|
-
- uses: actions/checkout@
|
37
|
+
- uses: actions/checkout@v4
|
37
38
|
- name: Install package dependencies
|
38
39
|
run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
|
39
40
|
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# 0.13.7 (Unreleased)
|
2
|
+
- [Change] Drop support for Ruby 2.6 due to incompatibilities in usage of `ObjectSpace::WeakMap`
|
3
|
+
- [Fix] Fix dangling Opaque references.
|
4
|
+
|
1
5
|
# 0.13.6 (2023-10-17)
|
2
6
|
* **[Feature]** Support transactions API in the producer
|
3
7
|
* [Enhancement] Add `raise_response_error` flag to the `Rdkafka::AbstractHandle`.
|
data/README.md
CHANGED
@@ -1,8 +1,13 @@
|
|
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
13
|
[librdkafka](https://github.com/edenhill/librdkafka/).
|
@@ -11,13 +16,7 @@ gem and targets Kafka 1.0+ and Ruby versions that are under security or
|
|
11
16
|
active maintenance. We remove Ruby version from our CI builds if 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
22
|
working towards feature completeness, you can track that here:
|
data/docker-compose.yml
CHANGED
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
|
|
data/lib/rdkafka/config.rb
CHANGED
@@ -14,7 +14,7 @@ module Rdkafka
|
|
14
14
|
# @private
|
15
15
|
@@error_callback = nil
|
16
16
|
# @private
|
17
|
-
@@opaques =
|
17
|
+
@@opaques = ObjectSpace::WeakMap.new
|
18
18
|
# @private
|
19
19
|
@@log_queue = Queue.new
|
20
20
|
|
@@ -164,7 +164,13 @@ module Rdkafka
|
|
164
164
|
Rdkafka::Bindings.rd_kafka_poll_set_consumer(kafka)
|
165
165
|
|
166
166
|
# Return consumer with Kafka client
|
167
|
-
Rdkafka::Consumer.new(
|
167
|
+
Rdkafka::Consumer.new(
|
168
|
+
Rdkafka::NativeKafka.new(
|
169
|
+
kafka,
|
170
|
+
run_polling_thread: false,
|
171
|
+
opaque: opaque
|
172
|
+
)
|
173
|
+
)
|
168
174
|
end
|
169
175
|
|
170
176
|
# Create a producer with this configuration.
|
@@ -182,7 +188,14 @@ module Rdkafka
|
|
182
188
|
Rdkafka::Bindings.rd_kafka_conf_set_dr_msg_cb(config, Rdkafka::Callbacks::DeliveryCallbackFunction)
|
183
189
|
# Return producer with Kafka client
|
184
190
|
partitioner_name = self[:partitioner] || self["partitioner"]
|
185
|
-
Rdkafka::Producer.new(
|
191
|
+
Rdkafka::Producer.new(
|
192
|
+
Rdkafka::NativeKafka.new(
|
193
|
+
native_kafka(config, :rd_kafka_producer),
|
194
|
+
run_polling_thread: true,
|
195
|
+
opaque: opaque
|
196
|
+
),
|
197
|
+
partitioner_name
|
198
|
+
).tap do |producer|
|
186
199
|
opaque.producer = producer
|
187
200
|
end
|
188
201
|
end
|
@@ -197,7 +210,13 @@ module Rdkafka
|
|
197
210
|
opaque = Opaque.new
|
198
211
|
config = native_config(opaque)
|
199
212
|
Rdkafka::Bindings.rd_kafka_conf_set_background_event_cb(config, Rdkafka::Callbacks::BackgroundEventCallbackFunction)
|
200
|
-
Rdkafka::Admin.new(
|
213
|
+
Rdkafka::Admin.new(
|
214
|
+
Rdkafka::NativeKafka.new(
|
215
|
+
native_kafka(config, :rd_kafka_producer),
|
216
|
+
run_polling_thread: true,
|
217
|
+
opaque: opaque
|
218
|
+
)
|
219
|
+
)
|
201
220
|
end
|
202
221
|
|
203
222
|
# Error that is returned by the underlying rdkafka error if an invalid configuration option is present.
|
data/lib/rdkafka/native_kafka.rb
CHANGED
@@ -4,8 +4,9 @@ module Rdkafka
|
|
4
4
|
# @private
|
5
5
|
# A wrapper around a native kafka that polls and cleanly exits
|
6
6
|
class NativeKafka
|
7
|
-
def initialize(inner, run_polling_thread:)
|
7
|
+
def initialize(inner, run_polling_thread:, opaque:)
|
8
8
|
@inner = inner
|
9
|
+
@opaque = opaque
|
9
10
|
# Lock around external access
|
10
11
|
@access_mutex = Mutex.new
|
11
12
|
# Lock around internal polling
|
@@ -112,6 +113,7 @@ module Rdkafka
|
|
112
113
|
|
113
114
|
Rdkafka::Bindings.rd_kafka_destroy(@inner)
|
114
115
|
@inner = nil
|
116
|
+
@opaque = nil
|
115
117
|
end
|
116
118
|
end
|
117
119
|
end
|
data/lib/rdkafka/version.rb
CHANGED
data/renovate.json
ADDED
@@ -7,8 +7,9 @@ describe Rdkafka::NativeKafka do
|
|
7
7
|
let(:native) { config.send(:native_kafka, config.send(:native_config), :rd_kafka_producer) }
|
8
8
|
let(:closing) { false }
|
9
9
|
let(:thread) { double(Thread) }
|
10
|
+
let(:opaque) { Rdkafka::Opaque.new }
|
10
11
|
|
11
|
-
subject(:client) { described_class.new(native, run_polling_thread: true) }
|
12
|
+
subject(:client) { described_class.new(native, run_polling_thread: true, opaque: opaque) }
|
12
13
|
|
13
14
|
before do
|
14
15
|
allow(Thread).to receive(:new).and_return(thread)
|
@@ -844,19 +844,25 @@ describe Rdkafka::Producer do
|
|
844
844
|
).producer
|
845
845
|
end
|
846
846
|
|
847
|
-
it 'expect to allow to produce within a transaction, finalize and ship data' do
|
847
|
+
it 'expect to allow to produce within a transaction, finalize and not ship data' do
|
848
848
|
producer.init_transactions
|
849
849
|
producer.begin_transaction
|
850
850
|
|
851
|
+
sleep(5)
|
852
|
+
|
851
853
|
handle1 = producer.produce(topic: 'produce_test_topic', payload: 'data1', partition: 1)
|
852
854
|
handle2 = producer.produce(topic: 'example_topic', payload: 'data2', partition: 0)
|
853
855
|
|
854
856
|
begin
|
855
|
-
producer.commit_transaction
|
857
|
+
producer.commit_transaction(15_000)
|
856
858
|
rescue Rdkafka::RdkafkaError => e
|
857
859
|
next unless e.abortable?
|
858
860
|
|
859
|
-
|
861
|
+
begin
|
862
|
+
producer.abort_transaction(15_000)
|
863
|
+
rescue Rdkafka::RdkafkaError => e
|
864
|
+
nil
|
865
|
+
end
|
860
866
|
|
861
867
|
expect { handle1.wait(max_wait_timeout: 15) }.to raise_error(Rdkafka::RdkafkaError)
|
862
868
|
expect { handle2.wait(max_wait_timeout: 15) }.to raise_error(Rdkafka::RdkafkaError)
|
data/spec/spec_helper.rb
CHANGED
@@ -107,6 +107,10 @@ def wait_for_unassignment(consumer)
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
+
def objects_of_type_count(type)
|
111
|
+
ObjectSpace.each_object(type).count
|
112
|
+
end
|
113
|
+
|
110
114
|
def notify_listener(listener, &block)
|
111
115
|
# 1. subscribe and poll
|
112
116
|
consumer.subscribe("consume_test_topic")
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: karafka-rdkafka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thijs Cadier
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
|
36
36
|
msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2023-10-
|
38
|
+
date: 2023-10-31 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: ffi
|
@@ -165,7 +165,7 @@ dependencies:
|
|
165
165
|
version: '0'
|
166
166
|
description: Modern Kafka client library for Ruby based on librdkafka
|
167
167
|
email:
|
168
|
-
-
|
168
|
+
- contact@karafka.io
|
169
169
|
executables: []
|
170
170
|
extensions:
|
171
171
|
- ext/Rakefile
|
@@ -182,7 +182,6 @@ files:
|
|
182
182
|
- README.md
|
183
183
|
- Rakefile
|
184
184
|
- certs/cert_chain.pem
|
185
|
-
- certs/karafka-pro.pem
|
186
185
|
- docker-compose.yml
|
187
186
|
- ext/README.md
|
188
187
|
- ext/Rakefile
|
@@ -211,6 +210,7 @@ files:
|
|
211
210
|
- lib/rdkafka/producer/delivery_handle.rb
|
212
211
|
- lib/rdkafka/producer/delivery_report.rb
|
213
212
|
- lib/rdkafka/version.rb
|
213
|
+
- renovate.json
|
214
214
|
- spec/rdkafka/abstract_handle_spec.rb
|
215
215
|
- spec/rdkafka/admin/create_topic_handle_spec.rb
|
216
216
|
- spec/rdkafka/admin/create_topic_report_spec.rb
|
@@ -251,7 +251,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
251
|
requirements:
|
252
252
|
- - ">="
|
253
253
|
- !ruby/object:Gem::Version
|
254
|
-
version: '2.
|
254
|
+
version: '2.7'
|
255
255
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
256
|
requirements:
|
257
257
|
- - ">="
|
metadata.gz.sig
CHANGED
Binary file
|
data/certs/karafka-pro.pem
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
-----BEGIN RSA PUBLIC KEY-----
|
2
|
-
MIIBigKCAYEApcd6ybskiNs9WUvBGVUE8GdWDehjZ9TyjSj/fDl/UcMYqY0R5YX9
|
3
|
-
tnYxEwZZRMdVltKWxr88Qmshh1IQz6CpJVbcfYjt/158pSGPm+AUua6tkLqIvZDM
|
4
|
-
ocFOMafmroI+BMuL+Zu5QH7HC2tkT16jclGYfMQkJjXVUQTk2UZr+94+8RlUz/CH
|
5
|
-
Y6hPA7xPgIyPfyPCxz1VWzAwXwT++NCJQPBr5MqT84LNSEzUSlR9pFNShf3UCUT+
|
6
|
-
8LWOvjFSNGmMMSsbo2T7/+dz9/FM02YG00EO0x04qteggwcaEYLFrigDN6/fM0ih
|
7
|
-
BXZILnMUqC/qrfW2YFg4ZqKZJuxaALqqkPxrkBDYqoqcAloqn36jBSke6tc/2I/J
|
8
|
-
2Afq3r53UoAbUH7h5I/L8YeaiA4MYjAuq724lHlrOmIr4D6yjYC0a1LGlPjLk869
|
9
|
-
2nsVXNgomhVb071E6amR+rJJnfvkdZgCmEBFnqnBV5A1u4qgNsa2rVcD+gJRvb2T
|
10
|
-
aQtjlQWKPx5xAgMBAAE=
|
11
|
-
-----END RSA PUBLIC KEY-----
|