Class: Karafka::Setup::Config
- Inherits:
-
Object
- Object
- Karafka::Setup::Config
- Extended by:
- Core::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
Class Method Summary collapse
-
.setup ⇒ Object
Configuring method.
Class Method Details
.setup ⇒ Object
Configuring method
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
# File 'lib/karafka/setup/config.rb', line 457 def setup(&) # Will prepare and verify license if present Licenser.prepare_and_verify(config.license) # Pre-setup configure all routing features that would need this Routing::Features::Base.pre_setup_all(config) # Will configure all the pro components # This needs to happen before end user configuration as the end user may overwrite some # of the pro defaults with custom components Pro::Loader.pre_setup_all(config) if Karafka.pro? # Wrap config in a proxy that intercepts producer block configuration proxy = ConfigProxy.new(config) # We need to check for the block presence here because user can just run setup without # any block given configure { yield(proxy) if block_given? } Contracts::Config.new.validate!( config.to_h, scope: %w[config] ) configure_components(proxy) # Install backwards-compatible forwarding so that gems (e.g. karafka-testing) that # still access config.internal.processing.strategy_selector (etc.) keep working after # the move to config.internal.processing.consumer_groups.* install_processing_cg_forwarders(config) # Refreshes the references that are cached that might have been changed by the config Karafka.refresh! # Post-setup configure all routing features that would need this Routing::Features::Base.post_setup_all(config) # Subscribe the critical errors listener so process-critical errors reported anywhere # in the framework escalate to a graceful shutdown. Subscribed before any other # internal listener (including the Pro post-setup subscriptions) so it reacts first config.monitor.subscribe(Instrumentation::CriticalErrorsListener.instance) # Runs things that need to be executed after config is defined and all the components # are also configured Pro::Loader.post_setup_all(config) if Karafka.pro? # Subscribe the assignments tracker so we can always query all current assignments config.monitor.subscribe(Instrumentation::AssignmentsTracker.instance) Karafka::App.initialized! end |