Sha256: 3f57db0750359a3d42b06a7b108dd2700516d1f0bde8fec22696af6de4d60e7c
Contents?: true
Size: 1.03 KB
Versions: 32
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true # frozen_string_literal: true module Karafka module Routing # Abstraction layer on top of groups of topics class Topics include Enumerable extend Forwardable def_delegators :@accumulator, :[], :size, :empty?, :last, :<< # @param topics_array [Array<Karafka::Routing::Topic>] array with topics def initialize(topics_array) @accumulator = topics_array.dup end # Yields each topic # # @param [Proc] block we want to yield with on each topic def each(&block) @accumulator.each(&block) end # Finds topic by its name # # @param topic_name [String] topic name # @return [Karafka::Routing::Topic] # @raise [Karafka::Errors::TopicNotFoundError] this should never happen. If you see it, # please create an issue. def find(topic_name) @accumulator.find { |topic| topic.name == topic_name } || raise(Karafka::Errors::TopicNotFoundError, topic_name) end end end end
Version data entries
32 entries across 32 versions & 1 rubygems