Class: Karafka::Messages::Metadata
- Inherits:
-
Struct
- Object
- Struct
- Karafka::Messages::Metadata
- 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
-
#deserializers ⇒ Object
Returns the value of attribute deserializers.
-
#message ⇒ Object
Returns the value of attribute message.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#partition ⇒ Object
Returns the value of attribute partition.
-
#raw_headers ⇒ Object
Returns the value of attribute raw_headers.
-
#raw_key ⇒ Object
Returns the value of attribute raw_key.
-
#received_at ⇒ Object
Returns the value of attribute received_at.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#topic ⇒ Object
Returns the value of attribute topic.
Instance Method Summary collapse
-
#headers ⇒ Object
Deserialized headers.
-
#key ⇒ Object
Deserialized key.
Instance Attribute Details
#deserializers ⇒ Object
Returns the value of attribute deserializers
6 7 8 |
# File 'lib/karafka/messages/metadata.rb', line 6 def deserializers @deserializers end |
#message ⇒ Object
Returns the value of attribute message
6 7 8 |
# File 'lib/karafka/messages/metadata.rb', line 6 def @message end |
#offset ⇒ Object
Returns the value of attribute offset
6 7 8 |
# File 'lib/karafka/messages/metadata.rb', line 6 def offset @offset end |
#partition ⇒ Object
Returns the value of attribute partition
6 7 8 |
# File 'lib/karafka/messages/metadata.rb', line 6 def partition @partition end |
#raw_headers ⇒ Object
Returns the value of attribute raw_headers
6 7 8 |
# File 'lib/karafka/messages/metadata.rb', line 6 def raw_headers @raw_headers end |
#raw_key ⇒ Object
Returns the value of attribute raw_key
6 7 8 |
# File 'lib/karafka/messages/metadata.rb', line 6 def raw_key @raw_key end |
#received_at ⇒ Object
Returns the value of attribute received_at
6 7 8 |
# File 'lib/karafka/messages/metadata.rb', line 6 def received_at @received_at end |
#timestamp ⇒ Object
Returns the value of attribute timestamp
6 7 8 |
# File 'lib/karafka/messages/metadata.rb', line 6 def @timestamp end |
#topic ⇒ Object
Returns the value of attribute topic
6 7 8 |
# File 'lib/karafka/messages/metadata.rb', line 6 def topic @topic end |
Instance Method Details
#headers ⇒ Object
Caching works as in #key, including falsy results
Returns deserialized headers. By default its a hash with keys and payload being strings.
34 35 36 37 38 39 40 |
# File 'lib/karafka/messages/metadata.rb', line 34 def headers return @headers if @headers_deserialized @headers = deserializers.headers.call(self) @headers_deserialized = true @headers end |
#key ⇒ Object
The result is cached after the first deserialization, including nil and other
falsy results (e.g. keyless messages), hence the explicit flag instead of a
truthiness check. As with Message#payload, the flag is set only after a successful
deserialization, so an error is not cached and the next access retries.
Returns deserialized key. By default in the raw string format.
23 24 25 26 27 28 29 |
# File 'lib/karafka/messages/metadata.rb', line 23 def key return @key if @key_deserialized @key = deserializers.key.call(self) @key_deserialized = true @key end |