Skip to content

Commit 0fd104d

Browse files
committed
Move client finalizer to bottom of class file
--- Changelog: refactor Refactoring: moveClass
1 parent d25b1fb commit 0fd104d

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

lib/rdkafka/producer.rb

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,6 @@ class Producer
99
# @return [Proc, nil]
1010
attr_reader :delivery_callback
1111

12-
class ClientFinalizer
13-
def initialize(client, polling_thread, reference_destroyer)
14-
@client = client
15-
@polling_thread = polling_thread
16-
@reference_destroyer = reference_destroyer
17-
end
18-
19-
def call(object_id)
20-
return unless @client
21-
22-
# Indicate to polling thread that we're closing
23-
@polling_thread[:closing] = true
24-
# Wait for the polling thread to finish up
25-
@polling_thread.join
26-
27-
Rdkafka::Bindings.rd_kafka_destroy(@client)
28-
29-
@reference_destroyer.call
30-
end
31-
end
32-
3312
# @private
3413
def initialize(native_kafka)
3514
@native_kafka = native_kafka
@@ -191,5 +170,27 @@ def call_delivery_callback(delivery_handle)
191170
def closed_producer_check(method)
192171
raise Rdkafka::ClosedProducerError.new(method) if @native_kafka.nil?
193172
end
173+
174+
class ClientFinalizer
175+
def initialize(client, polling_thread, reference_destroyer)
176+
@client = client
177+
@polling_thread = polling_thread
178+
@reference_destroyer = reference_destroyer
179+
end
180+
181+
def call(object_id)
182+
return unless @client
183+
184+
# Indicate to polling thread that we're closing
185+
@polling_thread[:closing] = true
186+
# Wait for the polling thread to finish up
187+
@polling_thread.join
188+
189+
Rdkafka::Bindings.rd_kafka_destroy(@client)
190+
191+
@reference_destroyer.call
192+
end
193+
end
194+
194195
end
195196
end

0 commit comments

Comments
 (0)