Class: Karafka::Web::Deserializer

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/web/deserializer.rb

Overview

Note:

We use symbolize_names because we want to use the same convention of hash building for producing, consuming and displaying metrics related data

Note:

We have to check if we compress the data, because older Web-UI versions were not compressing the payload.

Web reporting deserializer

Instance Method Summary collapse

Instance Method Details

#call(message) ⇒ Object

Returns deserialized data.

Parameters:

  • message (::Karafka::Messages::Message)

Returns:

  • (Object)

    deserialized data



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/karafka/web/deserializer.rb', line 15

def call(message)
  raw_payload = if message.headers.key?('zlib')
                  Zlib::Inflate.inflate(message.raw_payload)
                else
                  message.raw_payload
                end

  ::JSON.parse(
    raw_payload,
    symbolize_names: true
  )
end