rdkafka 0.12.0.beta.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a52f754380304d2a9bef30ecd2cbf0f33347cdb02254758f5452d9b9880a5bae
4
- data.tar.gz: ed3f56449ad95f679bb5e686117ff6590533bd70965679cedbf952a3d30e0cfb
3
+ metadata.gz: 821523c304fc7a1fbb2c7be2b58d98d56600b645b89fdb4093f976418650035d
4
+ data.tar.gz: '039b8e345fd8be5f295a293d64466071dbefd77d81b01460abb0fcf343a6bed3'
5
5
  SHA512:
6
- metadata.gz: 8e5d72b357d60352cabcac36e0257fc72d1ffcfd5f13bcca5652add92f3cac421941af3b2ae19015575490021287218a06755268727f3e07de5826c30d7e9f98
7
- data.tar.gz: 84a475f9167d598ad8499412a44c16019beaf77ec297f6d9c0879f27d0bcae079b0006bc880334c7e9d7310d9110250db69bdface85937cb1ec0abd5b56c4b2b
6
+ metadata.gz: 2c7ac2199a63aacd3b1420890981ed5d953ae5cdadb874886cc4e396fa1fd8f69333633319beef35a05a002d75d22335a526a126e518cc3fbbb877a1c11ef2f7
7
+ data.tar.gz: 5d23c6beec3759877013b040018111453e05c41238014b07a27c1a9d8b96e8af3bc037aacd1ebe89f856435cf0afb8e34a9f89443f87cf1a3682736efb79b4bd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.12.0
2
+ * Bumps librdkafka to 1.9.0
3
+
1
4
  # 0.11.0
2
5
  * Upgrade librdkafka to 1.8.2
3
6
  * Bump supported minimum Ruby version to 2.6
data/ext/Rakefile CHANGED
@@ -28,25 +28,16 @@ task :default => :clean do
28
28
  from_extension = 'so.1'
29
29
  to_extension = 'so'
30
30
  end
31
-
32
- # Get path to the compiled library
33
31
  lib_path = File.join(File.dirname(__FILE__), "ports/#{recipe.host}/librdkafka/#{Rdkafka::LIBRDKAFKA_VERSION}/lib/librdkafka.#{from_extension}")
34
-
35
- # Get target dir
36
- target_dir = ENV["RUBYARCHDIR"] || File.dirname(__FILE__)
37
-
38
- # Move the compliled library there
39
- FileUtils.mv(lib_path, File.join(target_dir, "librdkafka.#{to_extension}"))
40
-
32
+ FileUtils.mv(lib_path, File.join(File.dirname(__FILE__), "librdkafka.#{to_extension}"))
41
33
  # Cleanup files created by miniportile we don't need in the gem
42
- FileUtils.rm_rf File.join(target_dir, "tmp")
43
- FileUtils.rm_rf File.join(target_dir, "ports")
34
+ FileUtils.rm_rf File.join(File.dirname(__FILE__), "tmp")
35
+ FileUtils.rm_rf File.join(File.dirname(__FILE__), "ports")
44
36
  end
45
37
 
46
38
  task :clean do
47
- target_dir = ENV["RUBYARCHDIR"] || File.dirname(__FILE__)
48
- FileUtils.rm_f File.join(target_dir, "librdkafka.dylib")
49
- FileUtils.rm_f File.join(target_dir, "librdkafka.so")
39
+ FileUtils.rm_f File.join(File.dirname(__FILE__), "librdkafka.dylib")
40
+ FileUtils.rm_f File.join(File.dirname(__FILE__), "librdkafka.so")
50
41
  FileUtils.rm_rf File.join(File.dirname(__FILE__), "ports")
51
42
  FileUtils.rm_rf File.join(File.dirname(__FILE__), "tmp")
52
43
  end
@@ -97,7 +97,7 @@ module Rdkafka
97
97
  delivery_handle[:pending] = false
98
98
  # Call delivery callback on opaque
99
99
  if opaque = Rdkafka::Config.opaques[opaque_ptr.to_i]
100
- opaque.call_delivery_callback(Rdkafka::Producer::DeliveryReport.new(message[:partition], message[:offset], message[:err]))
100
+ opaque.call_delivery_callback(Rdkafka::Producer::DeliveryReport.new(message[:partition], message[:offset], message[:err]), delivery_handle)
101
101
  end
102
102
  end
103
103
  end
@@ -278,8 +278,8 @@ module Rdkafka
278
278
  attr_accessor :producer
279
279
  attr_accessor :consumer_rebalance_listener
280
280
 
281
- def call_delivery_callback(delivery_handle)
282
- producer.call_delivery_callback(delivery_handle) if producer
281
+ def call_delivery_callback(delivery_report, delivery_handle)
282
+ producer.call_delivery_callback(delivery_report, delivery_handle) if producer
283
283
  end
284
284
 
285
285
  def call_on_partitions_assigned(consumer, list)
@@ -9,6 +9,12 @@ module Rdkafka
9
9
  # @return [Proc, nil]
10
10
  attr_reader :delivery_callback
11
11
 
12
+ # @private
13
+ # Returns the number of arguments accepted by the callback, by default this is nil.
14
+ #
15
+ # @return [Integer, nil]
16
+ attr_reader :delivery_callback_arity
17
+
12
18
  # @private
13
19
  def initialize(client, partitioner_name)
14
20
  @client = client
@@ -19,7 +25,7 @@ module Rdkafka
19
25
  end
20
26
 
21
27
  # Set a callback that will be called every time a message is successfully produced.
22
- # The callback is called with a {DeliveryReport}
28
+ # The callback is called with a {DeliveryReport} and {DeliveryHandle}
23
29
  #
24
30
  # @param callback [Proc, #call] The callback
25
31
  #
@@ -27,6 +33,7 @@ module Rdkafka
27
33
  def delivery_callback=(callback)
28
34
  raise TypeError.new("Callback has to be callable") unless callback.respond_to?(:call)
29
35
  @delivery_callback = callback
36
+ @delivery_callback_arity = arity(callback)
30
37
  end
31
38
 
32
39
  # Close this producer and wait for the internal poll queue to empty.
@@ -151,8 +158,17 @@ module Rdkafka
151
158
  end
152
159
 
153
160
  # @private
154
- def call_delivery_callback(delivery_handle)
155
- @delivery_callback.call(delivery_handle) if @delivery_callback
161
+ def call_delivery_callback(delivery_report, delivery_handle)
162
+ return unless @delivery_callback
163
+
164
+ args = [delivery_report, delivery_handle].take(@delivery_callback_arity)
165
+ @delivery_callback.call(*args)
166
+ end
167
+
168
+ def arity(callback)
169
+ return callback.arity if callback.respond_to?(:arity)
170
+
171
+ callback.method(:call).arity
156
172
  end
157
173
 
158
174
  def closed_producer_check(method)
@@ -1,5 +1,5 @@
1
1
  module Rdkafka
2
- VERSION = "0.12.0.beta.2"
3
- LIBRDKAFKA_VERSION = "1.9.0-RC2"
4
- LIBRDKAFKA_SOURCE_SHA256 = "f38c7007d01c489c7b743d200a6760678f43b171b36886c4dda39d4a8d5aab59"
2
+ VERSION = "0.12.0"
3
+ LIBRDKAFKA_VERSION = "1.9.0"
4
+ LIBRDKAFKA_SOURCE_SHA256 = "59b6088b69ca6cf278c3f9de5cd6b7f3fd604212cd1c59870bc531c54147e889"
5
5
  end
@@ -49,6 +49,27 @@ describe Rdkafka::Producer do
49
49
  # Callback should have been called
50
50
  expect(@callback_called).to be true
51
51
  end
52
+
53
+ it "should provide handle" do
54
+ @callback_handle = nil
55
+
56
+ producer.delivery_callback = lambda { |_, handle| @callback_handle = handle }
57
+
58
+ # Produce a message
59
+ handle = producer.produce(
60
+ topic: "produce_test_topic",
61
+ payload: "payload",
62
+ key: "key"
63
+ )
64
+
65
+ # Wait for it to be delivered
66
+ handle.wait(max_wait_timeout: 15)
67
+
68
+ # Join the producer thread.
69
+ producer.close
70
+
71
+ expect(handle).to be @callback_handle
72
+ end
52
73
  end
53
74
 
54
75
  context "with a callable object" do
@@ -93,6 +114,36 @@ describe Rdkafka::Producer do
93
114
  expect(called_report.first.partition).to eq 1
94
115
  expect(called_report.first.offset).to be >= 0
95
116
  end
117
+
118
+ it "should provide handle" do
119
+ callback_handles = []
120
+ callback = Class.new do
121
+ def initialize(callback_handles)
122
+ @callback_handles = callback_handles
123
+ end
124
+
125
+ def call(_, handle)
126
+ @callback_handles << handle
127
+ end
128
+ end
129
+ producer.delivery_callback = callback.new(callback_handles)
130
+
131
+ # Produce a message
132
+ handle = producer.produce(
133
+ topic: "produce_test_topic",
134
+ payload: "payload",
135
+ key: "key"
136
+ )
137
+
138
+ # Wait for it to be delivered
139
+ handle.wait(max_wait_timeout: 15)
140
+
141
+ # Join the producer thread.
142
+ producer.close
143
+
144
+ # Callback should have been called
145
+ expect(handle).to be callback_handles.first
146
+ end
96
147
  end
97
148
 
98
149
  it "should not accept a callback that's not callable" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdkafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0.beta.2
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thijs Cadier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-12 00:00:00.000000000 Z
11
+ date: 2022-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -217,9 +217,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
217
  version: '2.6'
218
218
  required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - ">"
220
+ - - ">="
221
221
  - !ruby/object:Gem::Version
222
- version: 1.3.1
222
+ version: '0'
223
223
  requirements: []
224
224
  rubygems_version: 3.0.3
225
225
  signing_key: