Sha256: 1b6d4713647f547d0a5dd17bcda8c4c259d3052e2760657f021e4e19761bcba7
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
module Karafka module Responders # 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, optional: true) # @example Define topic that on which we want to respond multiple times # Karafka::Responders::Topic.new(:topic_name, multiple_usage: true) class Topic # Name of the topic on which we want to respond attr_reader :name # @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 def initialize(name, options) @name = name.to_s @options = options validate! end # @return [Boolean] is this a required topic (if not, it is optional) def required? return false if @options[:optional] @options[:required] || true end # @return [Boolean] do we expect to use it multiple times in a single respond flow def multiple_usage? @options[:multiple_usage] || false end private # Checks topic name with the same regexp as routing # @raise [Karafka::Errors::InvalidTopicName] raised when topic name is invalid def validate! raise Errors::InvalidTopicName, name if Routing::Route::NAME_FORMAT !~ name end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
karafka-0.5.0 | lib/karafka/responders/topic.rb |