class Karafka::Setup::Config

Configurator for setting up all the framework details that are required to make it work @note If you want to do some configurations after all of this is done, please add to

karafka/config a proper file (needs to inherit from Karafka::Setup::Configurators::Base
and implement setup method) after that everything will happen automatically

@note This config object allows to create a 1 level nesting (nodes) only. This should be

enough and will still keep the code simple

@see Karafka::Setup::Configurators::Base for more details about configurators api

Constants

CONTRACT

Contract for checking the config provided by the user

Public Class Methods

setup() { |config| ... } click to toggle source

Configuring method @yield Runs a block of code providing a config singleton instance to it @yieldparam [Karafka::Setup::Config] Karafka config instance

# File lib/karafka/setup/config.rb, line 201
def setup
  configure { |config| yield(config) }
end
setup_components() click to toggle source

Everything that should be initialized after the setup Components are in karafka/config directory and are all loaded one by one If you want to configure a next component, please add a proper file to config dir

# File lib/karafka/setup/config.rb, line 208
def setup_components
  config
    .internal
    .configurators
    .each { |configurator| configurator.call(config) }
end
validate!() click to toggle source

Validate config based on the config contract @return [Boolean] true if configuration is valid @raise [Karafka::Errors::InvalidConfigurationError] raised when configuration

doesn't match with the config contract
# File lib/karafka/setup/config.rb, line 219
def validate!
  validation_result = CONTRACT.call(config.to_h)

  return true if validation_result.success?

  raise Errors::InvalidConfigurationError, validation_result.errors.to_h
end