Module: Temporal::Testing::ScheduledWorkflows::Private::Store
- Defined in:
- lib/temporal/testing/scheduled_workflows.rb
Class Method Summary collapse
- .add(workflow_id:, cron_schedule:, executor_lambda:) ⇒ Object
- .clear_all ⇒ Object
- .execute(workflow_id:) ⇒ Object
- .execute_all ⇒ Object
- .schedules ⇒ Object
Class Method Details
.add(workflow_id:, cron_schedule:, executor_lambda:) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/temporal/testing/scheduled_workflows.rb', line 36 def add(workflow_id:, cron_schedule:, executor_lambda:) new_schedules = schedules.dup new_schedules[workflow_id] = cron_schedule @schedules = new_schedules.freeze new_scheduled_executions = scheduled_executions.dup new_scheduled_executions[workflow_id] = executor_lambda @scheduled_executions = new_scheduled_executions.freeze end |
.clear_all ⇒ Object
46 47 48 49 |
# File 'lib/temporal/testing/scheduled_workflows.rb', line 46 def clear_all @scheduled_executions = {}.freeze @schedules = {}.freeze end |
.execute(workflow_id:) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/temporal/testing/scheduled_workflows.rb', line 51 def execute(workflow_id:) unless scheduled_executions.key?(workflow_id) raise Temporal::Testing::WorkflowIDNotScheduled, "There is no workflow with id #{workflow_id} that was scheduled with Temporal.schedule_workflow.\n"\ "Options: #{scheduled_executions.keys}" end scheduled_executions[workflow_id].call end |
.execute_all ⇒ Object
61 62 63 |
# File 'lib/temporal/testing/scheduled_workflows.rb', line 61 def execute_all scheduled_executions.values.each(&:call) end |
.schedules ⇒ Object
32 33 34 |
# File 'lib/temporal/testing/scheduled_workflows.rb', line 32 def schedules @schedules ||= {}.freeze end |