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.
-
#multiple_usage? ⇒ Boolean
Do we expect to use it multiple times in a single respond flow.
-
#registered? ⇒ Boolean
Was usage of this topic registered or not.
-
#required? ⇒ Boolean
Is this a required topic (if not, it is optional).
-
#to_h ⇒ Hash
Hash with this topic attributes and options.
Constructor Details
#initialize(name, options) ⇒ Karafka::Responders::Topic
Returns topic description object.
19 20 21 22 |
# File 'lib/karafka/responders/topic.rb', line 19 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
14 15 16 |
# File 'lib/karafka/responders/topic.rb', line 14 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.
41 42 43 |
# File 'lib/karafka/responders/topic.rb', line 41 def async? @options.key?(:async) ? @options[:async] : false end |
#multiple_usage? ⇒ Boolean
Returns do we expect to use it multiple times in a single respond flow.
30 31 32 |
# File 'lib/karafka/responders/topic.rb', line 30 def multiple_usage? @options[:multiple_usage] || false end |
#registered? ⇒ Boolean
Returns was usage of this topic registered or not.
35 36 37 |
# File 'lib/karafka/responders/topic.rb', line 35 def registered? @options[:registered] == true end |
#required? ⇒ Boolean
Returns is this a required topic (if not, it is optional).
25 26 27 |
# File 'lib/karafka/responders/topic.rb', line 25 def required? @options.key?(:required) ? @options[:required] : true end |
#to_h ⇒ Hash
Returns hash with this topic attributes and options.
46 47 48 49 50 51 52 53 54 |
# File 'lib/karafka/responders/topic.rb', line 46 def to_h { name: name, multiple_usage: multiple_usage?, required: required?, registered: registered?, async: async? } end |