Class: EventEngine::Subscribers::DispatchSubscribersJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/event_engine/subscribers/dispatch_subscribers_job.rb

Overview

Runs an event's subscribers in a background worker. Enqueued by Processor for :background events, which dispatch their subscribers asynchronously without touching the outbox.

Instance Method Summary collapse

Instance Method Details

#perform(event_name, attrs) ⇒ void

This method returns an undefined value.

Parameters:

  • event_name (String)

    the emitted event's name

  • attrs (Hash)

    the event attributes used to rebuild the Event



12
13
14
15
# File 'app/jobs/event_engine/subscribers/dispatch_subscribers_job.rb', line 12

def perform(event_name, attrs)
  event = EventEngine::Event.new(**attrs.deep_symbolize_keys)
  Registry.subscribers_for(event_name).each { |subscriber| subscriber.new.handle(event) }
end