Module: Karafka::Pro::Cleaner::Messages::Message
- Defined in:
- lib/karafka/pro/cleaner/messages/message.rb
Overview
Extensions to the message that allow for granular memory control on a per message basis
Instance Method Summary collapse
-
#clean!(metadata: true) ⇒ Object
Cleans the message payload, headers, key and removes the deserialized data references This is useful when working with big messages that take a lot of space.
-
#cleaned? ⇒ Boolean
True if the message has been cleaned.
-
#payload ⇒ Object
Lazy-deserialized data (deserialized upon first request).
Instance Method Details
#clean!(metadata: true) ⇒ Object
Cleaning of message means we also clean its metadata (headers and key)
Metadata cleaning (headers and key) can be disabled by setting the metadata
argument to false.
Cleans the message payload, headers, key and removes the deserialized data references This is useful when working with big messages that take a lot of space.
After the message content is no longer needed, it can be removed so it does not consume space anymore.
37 38 39 40 41 42 43 |
# File 'lib/karafka/pro/cleaner/messages/message.rb', line 37 def clean!(metadata: true) @deserialized = false @raw_payload = false @payload = nil @metadata.clean! if end |
#cleaned? ⇒ Boolean
Returns true if the message has been cleaned.
20 21 22 |
# File 'lib/karafka/pro/cleaner/messages/message.rb', line 20 def cleaned? @raw_payload == false end |
#payload ⇒ Object
Returns lazy-deserialized data (deserialized upon first request).
14 15 16 17 |
# File 'lib/karafka/pro/cleaner/messages/message.rb', line 14 def payload # If message has already been cleaned, it cannot be deserialized again cleaned? ? raise(Errors::MessageCleanedError) : super end |