Class: Temporal::Testing::WorkflowExecution

Inherits:
Object
  • Object
show all
Defined in:
lib/temporal/testing/workflow_execution.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWorkflowExecution

Returns a new instance of WorkflowExecution.



8
9
10
11
# File 'lib/temporal/testing/workflow_execution.rb', line 8

def initialize
  @status = Workflow::ExecutionInfo::RUNNING_STATUS
  @futures = FutureRegistry.new
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/temporal/testing/workflow_execution.rb', line 6

def status
  @status
end

Instance Method Details

#complete_activity(token, result) ⇒ Object



29
30
31
32
# File 'lib/temporal/testing/workflow_execution.rb', line 29

def complete_activity(token, result)
  futures.complete(token, result)
  resume
end

#fail_activity(token, exception) ⇒ Object



34
35
36
37
# File 'lib/temporal/testing/workflow_execution.rb', line 34

def fail_activity(token, exception)
  futures.fail(token, exception)
  resume
end

#register_future(token, future) ⇒ Object



25
26
27
# File 'lib/temporal/testing/workflow_execution.rb', line 25

def register_future(token, future)
  futures.register(token, future)
end

#resumeObject



18
19
20
21
22
23
# File 'lib/temporal/testing/workflow_execution.rb', line 18

def resume
  fiber.resume
  @status = Workflow::ExecutionInfo::COMPLETED_STATUS unless fiber.alive?
rescue StandardError
  @status = Workflow::ExecutionInfo::FAILED_STATUS
end

#run(&block) ⇒ Object



13
14
15
16
# File 'lib/temporal/testing/workflow_execution.rb', line 13

def run(&block)
  @fiber = Fiber.new(&block)
  resume
end