Class: Collavre::SystemEvents::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
app/services/collavre/system_events/dispatcher.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dispatch(event_name, context) ⇒ Object



4
5
6
# File 'app/services/collavre/system_events/dispatcher.rb', line 4

def self.dispatch(event_name, context)
  new.dispatch(event_name, context)
end

Instance Method Details

#dispatch(event_name, context) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/services/collavre/system_events/dispatcher.rb', line 8

def dispatch(event_name, context)
  comment_id = context.dig("comment", "id")
  comment_user_id = context.dig("comment", "user_id")
  creative_id = context.dig("creative", "id")
  Rails.logger.info(
    "[SystemEvents::Dispatcher] event=#{event_name} " \
    "comment_id=#{comment_id} comment_user_id=#{comment_user_id} " \
    "creative_id=#{creative_id} " \
    "caller=#{caller_locations(1, 5)&.map { |l| "#{File.basename(l.path)}:#{l.lineno}" }&.join(' <- ')}"
  )
  # Delegate to AgentOrchestrator for unified routing/scheduling
  Orchestration::AgentOrchestrator.dispatch(event_name, context)
end