class Karafka::Responders::Topic
Topic
describes a single topic on which we want to respond with responding requirements @example Define topic (required by default)
Karafka::Responders::Topic.new(:topic_name, {}) #=> #<Karafka::Responders::Topic...
@example Define optional topic
Karafka::Responders::Topic.new(:topic_name, required: false)
Attributes
name[R]
Name of the topic on which we want to respond
Public Class Methods
new(name, options)
click to toggle source
@param name [Symbol, String] name of a topic on which we want to respond @param options [Hash] non-default options for this topic @return [Karafka::Responders::Topic] topic description object
# File lib/karafka/responders/topic.rb, line 17 def initialize(name, options) @name = name.to_s @options = options end
Public Instance Methods
async?()
click to toggle source
@return [Boolean] do we want to use async producer. Defaults to false as the sync producer
is safer and introduces less problems
# File lib/karafka/responders/topic.rb, line 39 def async? @options.key?(:async) ? @options[:async] : false end
registered?()
click to toggle source
@return [Boolean] was usage of this topic registered or not
# File lib/karafka/responders/topic.rb, line 28 def registered? @options[:registered] == true end
required?()
click to toggle source
@return [Boolean] is this a required topic (if not, it is optional)
# File lib/karafka/responders/topic.rb, line 23 def required? @options.key?(:required) ? @options[:required] : true end
serializer()
click to toggle source
@return [Class] Class to use to serialize messages for this topic
# File lib/karafka/responders/topic.rb, line 33 def serializer @options[:serializer] end
to_h()
click to toggle source
@return [Hash] hash with this topic attributes and options
# File lib/karafka/responders/topic.rb, line 44 def to_h { name: name, required: required?, registered: registered?, serializer: serializer, async: async? } end