Sha256: df99ba54d4081d3b275918b2c1d98590e9e8b2d69beea493923e0211d03cd732

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

module Karafka
  module Setup
    # Configurators module is used to enclose all the external dependencies configurations
    class Configurators
      # Karafka has come components that it relies on (like Celluloid or Sidekiq)
      # We need to configure all of them only when the framework was set up.
      # Any class that descends from this one will be automatically invoked upon setup (after it)
      # @example Configure an Example class
      #   class ExampleConfigurator < Base
      #     def setup
      #       ExampleClass.logger = Karafka.logger
      #       ExampleClass.redis = config.redis
      #     end
      #   end
      class Base
        extend ActiveSupport::DescendantsTracker

        attr_reader :config

        # @param config [Karafka::Config] config instance
        # @return [Karafka::Config::Base] configurator for a given component
        def initialize(config)
          @config = config
        end

        # This method needs to be implemented in a subclass
        def setup
          raise NotImplementedError
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
karafka-0.5.0.3 lib/karafka/setup/configurators/base.rb
karafka-0.5.0.2 lib/karafka/setup/configurators/base.rb
karafka-0.5.0.1 lib/karafka/setup/configurators/base.rb
karafka-0.5.0 lib/karafka/setup/configurators/base.rb