Class: Karafka::Setup::Config

Inherits:
Object
  • Object
show all
Extended by:
Dry::Configurable
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 nesting (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

See Also:

  • for more details about configurators api

Class Method Summary collapse

Class Method Details

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

Configuring method

Yields:

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

Yield Parameters:



198
199
200
# File 'lib/karafka/setup/config.rb', line 198

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



205
206
207
208
209
210
# File 'lib/karafka/setup/config.rb', line 205

def setup_components
  config
    .internal
    .configurators
    .each { |configurator| configurator.call(config) }
end

.validate!Boolean

Validate config based on the config contract

Returns:

  • (Boolean)

    true if configuration is valid

Raises:



216
217
218
219
220
221
222
# File 'lib/karafka/setup/config.rb', line 216

def validate!
  validation_result = CONTRACT.call(config.to_h)

  return true if validation_result.success?

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