Class: Textus::Workflow::EventEmitter

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/workflow/event_emitter.rb

Instance Method Summary collapse

Constructor Details

#initialize(workflow_queue, registry:) ⇒ EventEmitter

Returns a new instance of EventEmitter.



4
5
6
7
# File 'lib/textus/workflow/event_emitter.rb', line 4

def initialize(workflow_queue, registry:)
  @workflow_queue = workflow_queue
  @registry = registry
end

Instance Method Details

#emit(event_type:, key:, lane: "artifacts") ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/textus/workflow/event_emitter.rb', line 9

def emit(event_type:, key:, lane: "artifacts")
  workflows = @registry.workflows_for(event_type)
  workflows.each do |wf|
    @workflow_queue.push(
      event_type: event_type.to_s, workflow_type: wf.type,
      key:, lane:, max_attempts: wf.max_attempts
    )
  end
  workflows.size
end