Class: Karafka::Params::Params

Inherits:
Hash
  • Object
show all
Defined in:
lib/karafka/params/params.rb

Overview

It provides lazy loading not only until the first usage, but also allows us to skip using deserializer until we execute our logic. That way we can operate with heavy-deserialization data without slowing down the whole application.

Instance Method Summary collapse

Instance Method Details

#deserialize!Karafka::Params::Params

Returns This method will trigger deserializer execution. If we decide to retrieve data, deserializer will be executed to get data. Output of that will be merged to the current object. This object will be also marked as already deserialized, so we won’t deserialize it again.

Returns:

  • (Karafka::Params::Params)

    This method will trigger deserializer execution. If we decide to retrieve data, deserializer will be executed to get data. Output of that will be merged to the current object. This object will be also marked as already deserialized, so we won’t deserialize it again.



47
48
49
50
51
52
53
# File 'lib/karafka/params/params.rb', line 47

def deserialize!
  return self if self['deserialized']

  self['deserialized'] = true
  self['payload'] = deserialize
  self
end