Class: Textus::Workflow::Consumer

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

Constant Summary collapse

BACKOFF_DELAYS =
[10, 30, 60].freeze

Instance Method Summary collapse

Constructor Details

#initialize(registry:, container:, call:) ⇒ Consumer

Returns a new instance of Consumer.



6
7
8
9
10
# File 'lib/textus/workflow/consumer.rb', line 6

def initialize(registry:, container:, call:)
  @registry = registry
  @container = container
  @call = call
end

Instance Method Details

#consume(row, workflow_queue) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/textus/workflow/consumer.rb', line 12

def consume(row, workflow_queue)
  workflow_queue.mark_processing(row[:id])
  workflow = @registry.for(row[:workflow_type])
  Runner.new(workflow, container: @container, call: @call).run(row[:key])
  workflow_queue.complete(row[:id])
  row.merge(state: "done")
rescue StandardError => e
  handle_failure(row, workflow_queue, e)
end