Sha256: 68e3fcf57f34de8a699d2ec9ac4e732243bedf1f575eef5a5bc2c985cd7a7355

Contents?: true

Size: 1008 Bytes

Versions: 27

Compression:

Stored size: 1008 Bytes

Contents

# frozen_string_literal: true

module Karafka
  module Persistence
    # Persistence layer to store current thread messages consumer client for further use
    class Client
      # Thread.current key under which we store current thread messages consumer client
      PERSISTENCE_SCOPE = :client

      private_constant :PERSISTENCE_SCOPE

      class << self
        # @param client [Karafka::Connection::Client] messages consumer client of
        #   a current thread
        # @return [Karafka::Connection::Client] persisted messages consumer client
        def write(client)
          Thread.current[PERSISTENCE_SCOPE] = client
        end

        # @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
        def read
          Thread.current[PERSISTENCE_SCOPE] || raise(Errors::MissingClientError)
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
karafka-1.4.15 lib/karafka/persistence/client.rb
karafka-1.4.14 lib/karafka/persistence/client.rb
karafka-1.4.13 lib/karafka/persistence/client.rb
karafka-1.4.12 lib/karafka/persistence/client.rb
karafka-1.4.11 lib/karafka/persistence/client.rb
karafka-1.4.10 lib/karafka/persistence/client.rb
karafka-1.4.9 lib/karafka/persistence/client.rb
karafka-1.4.8 lib/karafka/persistence/client.rb
karafka-1.4.7 lib/karafka/persistence/client.rb
karafka-1.4.6 lib/karafka/persistence/client.rb
karafka-1.4.5 lib/karafka/persistence/client.rb
karafka-1.4.4 lib/karafka/persistence/client.rb
karafka-1.4.3 lib/karafka/persistence/client.rb
karafka-1.4.2 lib/karafka/persistence/client.rb
karafka-1.4.1 lib/karafka/persistence/client.rb
karafka-1.4.0 lib/karafka/persistence/client.rb
karafka-1.4.0.rc2 lib/karafka/persistence/client.rb
karafka-1.4.0.rc1 lib/karafka/persistence/client.rb
karafka-1.3.7 lib/karafka/persistence/client.rb
karafka-1.3.6 lib/karafka/persistence/client.rb