Skip to content

Commit

Permalink
module scope
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-szalwinski-he committed May 4, 2024
1 parent 4830298 commit c936f85
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/rdkafka/producer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
require_relative "oauth_token_refresher"

module Producer
CLIENTS = {}.freeze
@clients = {}

def self.from_name(client_name)
raise "Client not found: #{client_name}\n" if CLIENTS[client_name].nil?
raise "Client not found: #{client_name}\n" if @clients[client_name].nil?

CLIENTS[client_name]
@clients[client_name]
end

def self.start!(kafka_config)
Rdkafka::Config.oauthbearer_token_refresh_callback = method(:refresh_token)
@producer = Rdkafka::Config.new(kafka_config).producer(native_kafka_auto_start: false)
CLIENTS[@producer.name] = @producer
@clients[@producer.name] = @producer
@producer.start
end

Expand Down

0 comments on commit c936f85

Please sign in to comment.