Documentation
¶
Overview ¶
Package workflow is the workflow tier: a Base builds a consumer's request workflows, the one boundary observed in every environment and the owner of the transaction boundary. Every workflow is a core interfaces.Workflow, decorated in the tier's order (Tier), so a consumer declares no workflow interface of its own.
Index ¶
- func Tier() decorate.Tier
- type Base
- func (b Base) Func[In, Out any](op string, fn func(context.Context, In) (Out, error)) interfaces.Workflow[In, Out]
- func (b Base) Read[In, Out any](op string, pipe interfaces.Pipeline[In, Out]) interfaces.Workflow[In, Out]
- func (b Base) Tx[In, Out any](op string, pipe interfaces.Pipeline[In, Out]) interfaces.Workflow[In, Out]
- func (b Base) Wrap[In, Out any](op string, wf interfaces.Workflow[In, Out]) interfaces.Workflow[In, Out]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Base ¶ added in v0.0.7
type Base struct {
// contains filtered or unexported fields
}
Base builds a consumer's request workflows over the workflow tier's collaborators.
func NewBase ¶ added in v0.0.7
func NewBase(tx interfaces.TransactionManager, deps decorate.Deps) Base
NewBase builds the Base over tx (needed only by Tx) whose workflows are decorated with deps.
func (Base) Func ¶ added in v0.0.7
func (b Base) Func[In, Out any]( op string, fn func(context.Context, In) (Out, error), ) interfaces.Workflow[In, Out]
Func wraps fn as the decorated workflow named op; it runs as op's "Execute" operation. A nil fn panics, as a wiring bug.
func (Base) Read ¶ added in v0.0.7
func (b Base) Read[In, Out any]( op string, pipe interfaces.Pipeline[In, Out], ) interfaces.Workflow[In, Out]
Read runs pipe as the decorated workflow op, with no transaction.
func (Base) Tx ¶ added in v0.0.7
func (b Base) Tx[In, Out any]( op string, pipe interfaces.Pipeline[In, Out], ) interfaces.Workflow[In, Out]
Tx runs pipe in one transaction as the decorated workflow op: 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 with its code intact and a zero output, so a result whose transaction did not commit never reaches the caller.
func (Base) Wrap ¶ added in v0.0.7
func (b Base) Wrap[In, Out any]( op string, wf interfaces.Workflow[In, Out], ) interfaces.Workflow[In, Out]
Wrap decorates a custom workflow (a saga, a multi-transaction flow) as op.