workflow

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package workflow is the workflow tier: the one boundary observed in every environment and the only tier that opens a transaction. A consumer's workflow embeds a Base and runs each operation in one of three shapes: a read (Exec, no transaction), a command (ExecTx, one transaction) or a saga (Exec whose body commits each local step with InTx).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tier added in v0.0.7

func Tier() decorate.Tier

Tier is the workflow tier's decoration: recovery → logging → tracing → metrics → timeout, outermost first.

Types

type Base added in v0.0.7

type Base struct {

	// Subject runs the workflow's operations through the tier; it supplies Name and Exec.
	decorate.Subject
	// contains filtered or unexported fields
}

Base is the embeddable core of a workflow named by its Subject: Name and Exec (a read) are promoted from the Subject, ExecTx runs a command and InTx a saga's local step. The zero Base runs reads undecorated and refuses every transaction.

func NewBase added in v0.0.7

func NewBase(name string, tx interfaces.TransactionManager, deps decorate.Deps) Base

NewBase builds the Base for the workflow named name over tx (needed only by ExecTx and InTx), decorated with deps.

func (Base) ExecTx added in v0.0.10

func (b Base) ExecTx[R any](
	ctx context.Context,
	op string,
	fn func(context.Context) (R, error),
) (R, error)

ExecTx runs fn as the command op: one decorated operation whose body runs in one transaction, which commits when fn succeeds and rolls back when it fails. Every store call fn makes joins the transaction through the context. The body's error, or the commit's, is returned with its code intact and a zero result, so a result whose transaction did not commit never reaches the caller.

func (Base) InTx added in v0.0.10

func (b Base) InTx[R any](
	ctx context.Context,
	fn func(context.Context) (R, error),
) (R, error)

InTx runs fn in one transaction, undecorated: a saga's local step, inside the one decorated operation (Exec) that runs the saga, committing a write between remote calls or compensating one. A context already in a transaction, or a Base with no transaction manager, fails INTERNAL without running fn: a transaction never opens inside another.

func (Base) Pass added in v0.0.10

func (b Base) Pass(
	op string,
	pass interfaces.Workflow[struct{}, struct{}],
) interfaces.Workflow[struct{}, struct{}]

Pass runs a background loop's pass as the operation op, with no transaction: a pass that writes commits each write with InTx. Its method value is a loop.Decorator, so every pass is logged, counted, traced and recovered like a request.

type ResourceWorkflow added in v0.0.11

type ResourceWorkflow[T, P any, ID comparable, C, U any] struct {
	// contains filtered or unexported fields
}

ResourceWorkflow is the workflow-tier Base of interfaces.Resource over a resource's pipelines: each read runs as one operation with no transaction, and each write as one command in its own transaction.

func NewResource added in v0.0.11

func NewResource[T, P any, ID comparable, C, U any](
	flows Base,
	pipes interfaces.Resource[T, P, ID, C, U],
) ResourceWorkflow[T, P, ID, C, U]

NewResource builds the resource workflow running pipes through flows.

func (ResourceWorkflow[T, P, ID, C, U]) Create added in v0.0.11

func (w ResourceWorkflow[T, P, ID, C, U]) Create(ctx context.Context, in C) (*T, error)

Create persists a new entity built from in, a command.

func (ResourceWorkflow[T, P, ID, C, U]) Delete added in v0.0.11

func (w ResourceWorkflow[T, P, ID, C, U]) Delete(ctx context.Context, id ID) error

Delete removes the entity identified by id, a command.

func (ResourceWorkflow[T, P, ID, C, U]) Exists added in v0.0.11

func (w ResourceWorkflow[T, P, ID, C, U]) Exists(
	ctx context.Context,
	id ID,
) (bool, error)

Exists reports whether an entity identified by id exists, a read.

func (ResourceWorkflow[T, P, ID, C, U]) Get added in v0.0.11

func (w ResourceWorkflow[T, P, ID, C, U]) Get(ctx context.Context, id ID) (*T, error)

Get returns the entity identified by id, a read.

func (ResourceWorkflow[T, P, ID, C, U]) List added in v0.0.11

func (w ResourceWorkflow[T, P, ID, C, U]) List(
	ctx context.Context,
	params P,
	page types.PageRequest,
) (*types.Page[T], error)

List returns the page of entities params and page select, a read.

func (ResourceWorkflow[T, P, ID, C, U]) Update added in v0.0.11

func (w ResourceWorkflow[T, P, ID, C, U]) Update(
	ctx context.Context,
	id ID,
	in U,
) (*T, error)

Update modifies the entity identified by id with in, a command.

Jump to

Keyboard shortcuts

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