Module: Karafka::Pro::Cleaner::Messages::Metadata

Defined in:
lib/karafka/pro/cleaner/messages/metadata.rb

Overview

Extensions to the message metadata that allow for granular memory control on a per message basis

Instance Method Summary collapse

Instance Method Details

#clean!Object

Cleans the headers and key



31
32
33
34
35
36
# File 'lib/karafka/pro/cleaner/messages/metadata.rb', line 31

def clean!
  self.raw_headers = false
  self.raw_key = false
  @key = nil
  @headers = nil
end

#cleaned?Boolean

Returns true if the message metadata has been cleaned.

Returns:

  • (Boolean)

    true if the message metadata has been cleaned



26
27
28
# File 'lib/karafka/pro/cleaner/messages/metadata.rb', line 26

def cleaned?
  raw_headers == false
end

#headersObject

Returns deserialized headers. By default its a hash with keys and payload being strings.

Returns:

  • (Object)

    deserialized headers. By default its a hash with keys and payload being strings



21
22
23
# File 'lib/karafka/pro/cleaner/messages/metadata.rb', line 21

def headers
  cleaned? ? raise(Errors::MessageCleanedError) : super
end

#keyObject

Returns deserialized key. By default in the raw string format.

Returns:

  • (Object)

    deserialized key. By default in the raw string format.



15
16
17
# File 'lib/karafka/pro/cleaner/messages/metadata.rb', line 15

def key
  cleaned? ? raise(Errors::MessageCleanedError) : super
end