class Karafka::Persistence::Client

Persistence layer to store current thread messages consumer client for further use

Constants

PERSISTENCE_SCOPE

Thread.current key under which we store current thread messages consumer client

Public Class Methods

read() click to toggle source

@return [Karafka::Connection::Client] persisted messages consumer client @raise [Karafka::Errors::MissingClientError] raised when no thread messages consumer

client but we try to use it anyway
# File lib/karafka/persistence/client.rb, line 23
def read
  Thread.current[PERSISTENCE_SCOPE] || raise(Errors::MissingClientError)
end
write(client) click to toggle source

@param client [Karafka::Connection::Client] messages consumer client of

a current thread

@return [Karafka::Connection::Client] persisted messages consumer client

# File lib/karafka/persistence/client.rb, line 16
def write(client)
  Thread.current[PERSISTENCE_SCOPE] = client
end