class Karafka::Responders::Topic

Karafka::Responders::Topic.new(:topic_name, multiple_usage: true)
@example Define topic that on which we want to respond multiple times
Karafka::Responders::Topic.new(:topic_name, required: false)
@example Define optional topic
Karafka::Responders::Topic.new(:topic_name, {}) #=> #<Karafka::Responders::Topic…
@example Define topic (required by default)
Topic describes a single topic on which we want to respond with responding requirements

def async?

Returns:
  • (Boolean) - do we want to use async producer. Defaults to false as the sync producer
def async?
  @options.key?(:async) ? @options[:async] : false
end

def initialize(name, options)

Returns:
  • (Karafka::Responders::Topic) - topic description object

Parameters:
  • options (Hash) -- non-default options for this topic
  • name (Symbol, String) -- name of a topic on which we want to respond
def initialize(name, options)
  @name = name.to_s
  @options = options
end

def multiple_usage?

Returns:
  • (Boolean) - do we expect to use it multiple times in a single respond flow
def multiple_usage?
  @options[:multiple_usage] || false
end

def registered?

Returns:
  • (Boolean) - was usage of this topic registered or not
def registered?
  @options[:registered] == true
end

def required?

Returns:
  • (Boolean) - is this a required topic (if not, it is optional)
def required?
  @options.key?(:required) ? @options[:required] : true
end

def to_h

Returns:
  • (Hash) - hash with this topic attributes and options
def to_h
  {
    name: name,
    multiple_usage: multiple_usage?,
    required: required?,
    registered: registered?,
    async: async?
  }
end