Sha256: e9971f2a33483cdc7890f73253ed7747664f8cb1fb99b541b633d5c61b51bc06

Contents?: true

Size: 1.26 KB

Versions: 18

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Karafka
  module Routing
    # Default consumer mapper that builds consumer ids based on app id and consumer group name
    # Different mapper can be used in case of preexisting consumer names or for applying
    # other naming conventions not compatible wiih Karafkas client_id + consumer name concept
    #
    # @example Mapper for using consumer groups without a client_id prefix
    #   module MyMapper
    #     def self.call(raw_consumer_group_name)
    #       raw_consumer_group_name
    #     end
    #   end
    #
    # @example Mapper for replacing "_" with "." in topic names
    #   module MyMapper
    #     def self.call(raw_consumer_group_name)
    #       [
    #         Dry::Inflector.new.underscore(Karafka::App.config.client_id.to_s),
    #         raw_consumer_group_name
    #       ].join('_').gsub('_', '.')
    #     end
    #   end
    module ConsumerMapper
      # @param raw_consumer_group_name [String, Symbol] string or symbolized consumer group name
      # @return [String] remapped final consumer group name
      def self.call(raw_consumer_group_name)
        client_name = Dry::Inflector.new.underscore(Karafka::App.config.client_id.to_s)
        "#{client_name}_#{raw_consumer_group_name}"
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
karafka-1.2.13 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.12 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.11 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.10 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.9 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.8 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.7 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.6 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.5 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.4 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.3 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.2 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.1 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.0 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.0.beta4 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.0.beta3 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.0.beta2 lib/karafka/routing/consumer_mapper.rb
karafka-1.2.0.beta1 lib/karafka/routing/consumer_mapper.rb