Class: Karafka::Web::Pro::Loader
- Inherits:
-
Object
- Object
- Karafka::Web::Pro::Loader
- Defined in:
- lib/karafka/web/pro/loader.rb
Overview
Loader requires and loads all the pro components only when they are needed
Class Method Summary collapse
-
.load_on_late_setup ⇒ Object
This loads the pro components into memory in case someone required karafka-web prior to the license usage.
-
.post_setup_all(config) ⇒ Object
Runs post setup features configuration operations.
-
.pre_setup_all(config) ⇒ Object
Loads all the Web UI pro components and configures them wherever it is expected.
Class Method Details
.load_on_late_setup ⇒ Object
This loads the pro components into memory in case someone required karafka-web prior to the license usage. This can happen for users with complex require flows, where Karafka license is not part of the standard flow
In such cases Web may not notice that Karafka should operate in a Pro mode when it is being required via Zeitwerk. In such cases we load Pro components prior to the setup.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/karafka/web/pro/loader.rb', line 43 def load_on_late_setup return if defined?(Karafka::Web::Pro::Commanding) loader = Zeitwerk::Loader.new loader.push_dir( File.join(Karafka::Web.gem_root, "lib/karafka/web/pro"), namespace: Karafka::Web::Pro ) loader.setup loader.eager_load end |
.post_setup_all(config) ⇒ Object
Runs post setup features configuration operations
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/karafka/web/pro/loader.rb', line 83 def post_setup_all(config) Commanding.post_setup(config) Ui::Lib::Branding.post_setup(config) Ui::Lib::Policies.post_setup(config) Ui::Lib::Search.post_setup(config) config.commanding.listeners.each do |listener| ::Karafka::App.monitor.subscribe(listener) end end |
.pre_setup_all(config) ⇒ Object
Loads all the Web UI pro components and configures them wherever it is expected
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/karafka/web/pro/loader.rb', line 59 def pre_setup_all(config) # Expand the config with commanding configuration config.instance_eval do setting(:commanding, default: Commanding::Config.config) end # Expand UI config with extra search capabilities settings config.ui.instance_eval do setting(:branding, default: Ui::Lib::Branding::Config.config) setting(:policies, default: Ui::Lib::Policies::Config.config) setting(:search, default: Ui::Lib::Search::Config.config) setting :topics do setting :management do # Should we allow users to manage topics (edit config, resize, etc) from the UI setting(:active, default: true) end end end end |