module Temporal::Testing::ScheduledWorkflows::Private::Store

Public Class Methods

add(workflow_id:, cron_schedule:, executor_lambda:) click to toggle source
# 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() click to toggle source
# File lib/temporal/testing/scheduled_workflows.rb, line 46
def clear_all
  @scheduled_executions = {}.freeze
  @schedules = {}.freeze
end
execute(workflow_id:) click to toggle source
# 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() click to toggle source
# File lib/temporal/testing/scheduled_workflows.rb, line 61
def execute_all
  scheduled_executions.values.each(&:call)
end
schedules() click to toggle source
# File lib/temporal/testing/scheduled_workflows.rb, line 32
def schedules
  @schedules ||= {}.freeze
end

Private Class Methods

scheduled_executions() click to toggle source
# File lib/temporal/testing/scheduled_workflows.rb, line 67
def scheduled_executions
  @scheduled_executions ||= {}.freeze
end