Module: Julewire::Karafka::ForkHooks
- Defined in:
- lib/julewire/karafka/fork_hooks.rb
Class Method Summary collapse
- .handle(event_name, _event) ⇒ Object
- .subscribe!(monitor, configuration: Configuration.new) ⇒ Object
Class Method Details
.handle(event_name, _event) ⇒ Object
29 30 31 32 33 |
# File 'lib/julewire/karafka/fork_hooks.rb', line 29 def handle(event_name, _event) IntegrationHealth.with_failure_health(action: :after_fork, component: :fork_hooks, event: event_name) do Julewire.after_fork! end end |
.subscribe!(monitor, configuration: Configuration.new) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/julewire/karafka/fork_hooks.rb', line 14 def subscribe!(monitor, configuration: Configuration.new) return unless configuration.enabled? return unless monitor.respond_to?(:subscribe) state = INSTALL_STATE.fetch_or_store(monitor) { { events: [].freeze }.freeze } subscribed_events = Array(state[:events]).dup EVENTS.each do |event_name| next if subscribed_events.include?(event_name) subscribed_events << event_name if subscribe_event(monitor, event_name) end INSTALL_STATE.store(monitor, { events: subscribed_events.freeze }.freeze) monitor end |