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.
62 63 64 65 66 67 68 |
# File 'lib/karafka/pro/cleaner/messages/message.rb', line 62 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.
45 46 47 |
# File 'lib/karafka/pro/cleaner/messages/message.rb', line 45 def cleaned? @raw_payload == false end |
#payload ⇒ Object
Returns lazy-deserialized data (deserialized upon first request).
39 40 41 42 |
# File 'lib/karafka/pro/cleaner/messages/message.rb', line 39 def payload # If message has already been cleaned, it cannot be deserialized again cleaned? ? raise(Errors::MessageCleanedError) : super end |