Class: Karafka::Persistence::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/persistence/client.rb

Overview

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

Constant Summary collapse

PERSISTENCE_SCOPE =

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

:client

Class Method Summary collapse

Class Method Details

.readKarafka::Connection::Client

Returns persisted messages consumer client.

Returns:

Raises:

  • (Karafka::Errors::MissingConsumer)

    raised when no thread messages consumer client but we try to use it anyway



20
21
22
# File 'lib/karafka/persistence/client.rb', line 20

def self.read
  Thread.current[PERSISTENCE_SCOPE] || raise(Errors::MissingClient)
end

.write(client) ⇒ Karafka::Connection::Client

Returns persisted messages consumer client.

Parameters:

Returns:



13
14
15
# File 'lib/karafka/persistence/client.rb', line 13

def self.write(client)
  Thread.current[PERSISTENCE_SCOPE] = client
end