Help us shape the future of Go! Take the 2026 Go Developer Survey

workflow

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package workflow provides the base workflow implementation.

BaseWorkflow wraps an orchestration function and implements the Workflow[In, Out] interface from core. It serves as the innermost layer in a decorator chain — decorators (logging, metrics) wrap BaseWorkflow to add cross-cutting concerns without modifying the orchestration logic.

Unlike pipelines (pure stateless transformations), workflows coordinate stateful operations across services, pipelines, repositories, and caches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTxWorkflow added in v0.3.2

func NewTxWorkflow[In, Out any](
	txMgr interfaces.TransactionManager,
	pipe interfaces.Pipeline[In, Out],
) interfaces.Workflow[In, Out]

NewTxWorkflow returns a workflow that runs pipe inside one transaction opened by txMgr: the pipeline sees the transaction's context, so every repository call it makes joins the transaction, which commits when the pipeline succeeds and rolls back when it fails. The pipeline's error, or the commit's, is returned unchanged (its code intact) with a zero output — a result whose transaction did not commit never reaches the caller.

Types

type BaseWorkflow

type BaseWorkflow[In any, Out any] struct {
	// contains filtered or unexported fields
}

BaseWorkflow wraps an orchestration function and implements the Workflow[In, Out] interface. It provides a functional escape hatch for simple workflows, though workflows are typically stateful (holding service/pipeline/cache references).

func NewBaseWorkflow

func NewBaseWorkflow[In, Out any](
	fn func(context.Context, In) (Out, error),
) *BaseWorkflow[In, Out]

NewBaseWorkflow creates a new BaseWorkflow wrapping the given function. Panics if fn is nil.

func (*BaseWorkflow[In, Out]) Execute

func (w *BaseWorkflow[In, Out]) Execute(ctx context.Context, input In) (Out, error)

Execute runs the wrapped orchestration function. Context is passed through for cancellation and tracing support.

Directories

Path Synopsis
Package decorators provides fluent decorator composition for workflows.
Package decorators provides fluent decorator composition for workflows.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL