Class: Karafka::Responders::Topic
- Inherits:
-
Object
- Object
- Karafka::Responders::Topic
- Defined in:
- lib/karafka/responders/topic.rb
Overview
Topic describes a single topic on which we want to respond with responding requirements
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Name of the topic on which we want to respond.
Instance Method Summary collapse
-
#async? ⇒ Boolean
Do we want to use async producer.
-
#initialize(name, options) ⇒ Karafka::Responders::Topic
constructor
Topic description object.
-
#registered? ⇒ Boolean
Was usage of this topic registered or not.
-
#required? ⇒ Boolean
Is this a required topic (if not, it is optional).
-
#serializer ⇒ Class
Class to use to serialize messages for this topic.
-
#to_h ⇒ Hash
Hash with this topic attributes and options.
Constructor Details
#initialize(name, options) ⇒ Karafka::Responders::Topic
Returns topic description object.
17 18 19 20 |
# File 'lib/karafka/responders/topic.rb', line 17 def initialize(name, ) @name = name.to_s @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Name of the topic on which we want to respond
12 13 14 |
# File 'lib/karafka/responders/topic.rb', line 12 def name @name end |
Instance Method Details
#async? ⇒ Boolean
Returns do we want to use async producer. Defaults to false as the sync producer is safer and introduces less problems.
39 40 41 |
# File 'lib/karafka/responders/topic.rb', line 39 def async? @options.key?(:async) ? @options[:async] : false end |
#registered? ⇒ Boolean
Returns was usage of this topic registered or not.
28 29 30 |
# File 'lib/karafka/responders/topic.rb', line 28 def registered? @options[:registered] == true end |
#required? ⇒ Boolean
Returns is this a required topic (if not, it is optional).
23 24 25 |
# File 'lib/karafka/responders/topic.rb', line 23 def required? @options.key?(:required) ? @options[:required] : true end |
#serializer ⇒ Class
Returns Class to use to serialize messages for this topic.
33 34 35 |
# File 'lib/karafka/responders/topic.rb', line 33 def serializer @options[:serializer] end |
#to_h ⇒ Hash
Returns hash with this topic attributes and options.
44 45 46 47 48 49 50 51 52 |
# File 'lib/karafka/responders/topic.rb', line 44 def to_h { name: name, required: required?, registered: registered?, serializer: serializer, async: async? } end |