Skip to main content

Introduction to Workflows

Temporal Workflows orchestrate your Activities.

They are resilient - they can run and keep running for years, even if the underlying infrastructure fails. If the application itself crashes, Temporal will automatically recreate its Workflow’s pre-failure state so it can continue right where it left off.

In our reimbursement example, if the network fails right after the withdrawal but before the deposit, Temporal recreates the Workflow Execution from its last known state and continues as if no failure ever occurred.

This Workflow orchestrates our two Activities.

require 'temporalio/workflow'
require_relative 'activities'

class ReimbursementWorkflow < Temporalio::Workflow::Definition
def execute(user_id, amount)
Temporalio::Workflow.execute_activity(
WithdrawMoneyActivity,
amount,
)

Temporalio::Workflow.execute_activity(
DepositMoneyActivity,
amount,
)

"reimbursement to #{user_id} successfully complete"
end
end
4 / 9