Workflows & activities
Workflows orchestrate; activities do. The workflow method describes the durable control flow, while every side effect — HTTP calls, emails, database writes — lives in an activity so it can be retried and recorded exactly once.
Defining a workflow
Section titled “Defining a workflow”[Workflow("greeting")]public sealed class GreetingWorkflow{ [WorkflowRun] public async ValueTask<string> RunAsync( IWorkflowContext ctx, string name, CancellationToken cancellationToken ) { // ... }}Defining activities
Section titled “Defining activities”public sealed class EmailActivities{ [Activity("send-welcome")] public string SendWelcome(string email) { // side effects go here }}Calling activities from a workflow
Section titled “Calling activities from a workflow”var receipt = await ctx.Activity( (PaymentActivities a) => a.Charge(input.UserName, input.Amount), cancellationToken);Registration
Section titled “Registration”builder.Services.AddPgWorkflows(pg => pg.UsePostgres(connectionString) .AddWorkflow<GreetingWorkflow>() .AddActivities<EmailActivities>());