Class: Karafka::Setup::Config

Inherits:
Object
  • Object
show all
Extended by:
Dry::Configurable, Callbacks::Config
Defined in:
lib/karafka/setup/config.rb

Overview

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 nestings (nodes) only. This should be enough and will still keep the code simple

Configurator for setting up all the framework details that are required to make it work

Class Method Summary collapse

Methods included from Callbacks::Config

extended

Class Method Details

.setup {|Karafka| ... } ⇒ Object

Configurating method

Yields:

  • Runs a block of code providing a config singleton instance to it

Yield Parameters:



165
166
167
# File 'lib/karafka/setup/config.rb', line 165

def setup
  configure { |config| yield(config) }
end

.setup_componentsObject

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



172
173
174
175
176
177
# File 'lib/karafka/setup/config.rb', line 172

def setup_components
  [
    Configurators::Params,
    Configurators::WaterDrop
  ].each { |klass| klass.setup(config) }
end

.validate!Boolean

Validate config based on ConfigurationSchema

Returns:

  • (Boolean)

    true if configuration is valid

Raises:



183
184
185
186
187
188
189
# File 'lib/karafka/setup/config.rb', line 183

def validate!
  validation_result = Karafka::Schemas::Config.call(config.to_h)

  return true if validation_result.success?

  raise Errors::InvalidConfiguration, validation_result.errors
end