Module: Karafka::Routing::Features::Deserializers::Topic
- Defined in:
- lib/karafka/routing/features/deserializers/topic.rb
Overview
Routing topic deserializers API. It allows to configure deserializers for various components of each message.
Instance Method Summary collapse
-
#deserializer(payload) ⇒ Object
Supports pre 2.4 format where only payload deserializer could be defined.
-
#deserializers(payload: ::Karafka::Deserializers::Payload.new, key: ::Karafka::Deserializers::Key.new, headers: ::Karafka::Deserializers::Headers.new) ⇒ Object
Allows for setting all the deserializers with standard defaults.
-
#deserializers? ⇒ Boolean
Deserializers are always active.
-
#to_h ⇒ Hash
Topic setup hash.
Instance Method Details
#deserializer(payload) ⇒ Object
Supports pre 2.4 format where only payload deserializer could be defined. We do not retire this format because it is not bad when users do not do anything advanced with key or headers
32 33 34 |
# File 'lib/karafka/routing/features/deserializers/topic.rb', line 32 def deserializer(payload) deserializers(payload: payload) end |
#deserializers(payload: ::Karafka::Deserializers::Payload.new, key: ::Karafka::Deserializers::Key.new, headers: ::Karafka::Deserializers::Headers.new) ⇒ Object
Allows for setting all the deserializers with standard defaults
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/karafka/routing/features/deserializers/topic.rb', line 15 def deserializers( payload: ::Karafka::Deserializers::Payload.new, key: ::Karafka::Deserializers::Key.new, headers: ::Karafka::Deserializers::Headers.new ) @deserializers ||= Config.new( active: true, payload: payload, key: key, headers: headers ) end |
#deserializers? ⇒ Boolean
Returns Deserializers are always active.
37 38 39 |
# File 'lib/karafka/routing/features/deserializers/topic.rb', line 37 def deserializers? deserializers.active? end |
#to_h ⇒ Hash
Returns topic setup hash.
42 43 44 45 46 |
# File 'lib/karafka/routing/features/deserializers/topic.rb', line 42 def to_h super.merge( deserializers: deserializers.to_h ).freeze end |