Class: Karafka::Messages::Metadata

Inherits:
Struct
  • Object
show all
Defined in:
lib/karafka/messages/metadata.rb

Overview

Single message metadata details that can be accessed without the need of deserialization.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#deserializersObject

Returns the value of attribute deserializers

Returns:

  • (Object)

    the current value of deserializers



6
7
8
# File 'lib/karafka/messages/metadata.rb', line 6

def deserializers
  @deserializers
end

#messageObject

Returns the value of attribute message

Returns:

  • (Object)

    the current value of message



6
7
8
# File 'lib/karafka/messages/metadata.rb', line 6

def message
  @message
end

#offsetObject

Returns the value of attribute offset

Returns:

  • (Object)

    the current value of offset



6
7
8
# File 'lib/karafka/messages/metadata.rb', line 6

def offset
  @offset
end

#partitionObject

Returns the value of attribute partition

Returns:

  • (Object)

    the current value of partition



6
7
8
# File 'lib/karafka/messages/metadata.rb', line 6

def partition
  @partition
end

#raw_headersObject

Returns the value of attribute raw_headers

Returns:

  • (Object)

    the current value of raw_headers



6
7
8
# File 'lib/karafka/messages/metadata.rb', line 6

def raw_headers
  @raw_headers
end

#raw_keyObject

Returns the value of attribute raw_key

Returns:

  • (Object)

    the current value of raw_key



6
7
8
# File 'lib/karafka/messages/metadata.rb', line 6

def raw_key
  @raw_key
end

#received_atObject

Returns the value of attribute received_at

Returns:

  • (Object)

    the current value of received_at



6
7
8
# File 'lib/karafka/messages/metadata.rb', line 6

def received_at
  @received_at
end

#timestampObject

Returns the value of attribute timestamp

Returns:

  • (Object)

    the current value of timestamp



6
7
8
# File 'lib/karafka/messages/metadata.rb', line 6

def timestamp
  @timestamp
end

#topicObject

Returns the value of attribute topic

Returns:

  • (Object)

    the current value of topic



6
7
8
# File 'lib/karafka/messages/metadata.rb', line 6

def topic
  @topic
end

Instance Method Details

#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



27
28
29
30
31
# File 'lib/karafka/messages/metadata.rb', line 27

def headers
  return @headers if @headers

  @headers = deserializers.headers.call(self)
end

#keyObject

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

Returns:

  • (Object)

    deserialized key. By default in the raw string format.



19
20
21
22
23
# File 'lib/karafka/messages/metadata.rb', line 19

def key
  return @key if @key

  @key = deserializers.key.call(self)
end