From d784d263b0541215f3b166240cd1bcac7915f329 Mon Sep 17 00:00:00 2001 From: Nasar Khan Date: Fri, 3 May 2024 16:03:31 -0400 Subject: [PATCH] close kafka admin client connection --- lib/manageiq/messaging/kafka/client.rb | 5 ++++- lib/manageiq/messaging/kafka/common.rb | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/manageiq/messaging/kafka/client.rb b/lib/manageiq/messaging/kafka/client.rb index f99f78a..f35b1b6 100644 --- a/lib/manageiq/messaging/kafka/client.rb +++ b/lib/manageiq/messaging/kafka/client.rb @@ -56,6 +56,9 @@ def ack(ack_ref) end def close + @admin&.close + @admin = nil + @producer&.close @producer = nil @@ -65,7 +68,7 @@ def close # list all topics def topics - kafka_client.admin.metadata.topics.map { |topic| topic[:topic_name] } + admin.metadata.topics.map { |topic| topic[:topic_name] } end private diff --git a/lib/manageiq/messaging/kafka/common.rb b/lib/manageiq/messaging/kafka/common.rb index 24679e4..78f97a1 100644 --- a/lib/manageiq/messaging/kafka/common.rb +++ b/lib/manageiq/messaging/kafka/common.rb @@ -8,6 +8,10 @@ module Common private + def admin + @admin ||= kafka_client.admin + end + def producer @producer ||= kafka_client.producer end