superflow

package
v1.37.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Hostname = superflowapi.Hostname
	Version  = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Intermediate

type Intermediate struct {
	*connector.Connector
	ToDo
}

Intermediate extends and customizes the generic base connector.

func NewIntermediate

func NewIntermediate(impl ToDo) *Intermediate

NewIntermediate creates a new instance of the intermediate.

type Mock

type Mock struct {
	*Intermediate
	// contains filtered or unexported fields
}

Mock is a mockable version of the microservice, allowing functions, event sinks and web handlers to be mocked.

func NewMock

func NewMock() *Mock

NewMock creates a new mockable version of the microservice.

func (*Mock) ErrorHandler

func (svc *Mock) ErrorHandler(ctx context.Context, flow *workflow.Flow) (err error)

ErrorHandler executes the mock handler.

func (*Mock) MockErrorHandler

func (svc *Mock) MockErrorHandler(handler func(ctx context.Context, flow *workflow.Flow) (err error)) *Mock

MockErrorHandler sets up a mock handler for ErrorHandler.

func (*Mock) MockRunSuperSub added in v1.37.0

func (svc *Mock) MockRunSuperSub(handler func(ctx context.Context, flow *workflow.Flow) (err error)) *Mock

MockRunSuperSub sets up a mock handler for RunSuperSub.

func (*Mock) MockSubTaskA

func (svc *Mock) MockSubTaskA(handler func(ctx context.Context, flow *workflow.Flow) (err error)) *Mock

MockSubTaskA sets up a mock handler for SubTaskA.

func (*Mock) MockSubTaskB

func (svc *Mock) MockSubTaskB(handler func(ctx context.Context, flow *workflow.Flow) (err error)) *Mock

MockSubTaskB sets up a mock handler for SubTaskB.

func (*Mock) MockSuper

func (svc *Mock) MockSuper(handler func(ctx context.Context, flow *workflow.Flow, items []string, useSubgraph bool, behaviors map[string]superflowapi.TaskBehavior) (err error)) *Mock

MockSuper sets up a mock handler for the Super workflow. The handler receives typed inputs from the workflow's state and returns typed outputs. A nil handler clears the mock.

func (*Mock) MockSuperSub

func (svc *Mock) MockSuperSub(handler func(ctx context.Context, flow *workflow.Flow, behaviors map[string]superflowapi.TaskBehavior) (err error)) *Mock

MockSuperSub sets up a mock handler for the SuperSub workflow. The handler receives typed inputs from the workflow's state and returns typed outputs. A nil handler clears the mock.

func (*Mock) MockTaskA

func (svc *Mock) MockTaskA(handler func(ctx context.Context, flow *workflow.Flow) (err error)) *Mock

MockTaskA sets up a mock handler for TaskA.

func (*Mock) MockTaskB

func (svc *Mock) MockTaskB(handler func(ctx context.Context, flow *workflow.Flow) (err error)) *Mock

MockTaskB sets up a mock handler for TaskB.

func (*Mock) MockTaskC

func (svc *Mock) MockTaskC(handler func(ctx context.Context, flow *workflow.Flow) (err error)) *Mock

MockTaskC sets up a mock handler for TaskC.

func (*Mock) MockTaskD

func (svc *Mock) MockTaskD(handler func(ctx context.Context, flow *workflow.Flow) (err error)) *Mock

MockTaskD sets up a mock handler for TaskD.

func (*Mock) MockTaskE

func (svc *Mock) MockTaskE(handler func(ctx context.Context, flow *workflow.Flow) (err error)) *Mock

MockTaskE sets up a mock handler for TaskE.

func (*Mock) MockTaskZ

func (svc *Mock) MockTaskZ(handler func(ctx context.Context, flow *workflow.Flow) (err error)) *Mock

MockTaskZ sets up a mock handler for TaskZ.

func (*Mock) OnShutdown

func (svc *Mock) OnShutdown(ctx context.Context) (err error)

OnShutdown is called when the microservice is shut down.

func (*Mock) OnStartup

func (svc *Mock) OnStartup(ctx context.Context) (err error)

OnStartup is called when the microservice is started up.

func (*Mock) RunSuperSub added in v1.37.0

func (svc *Mock) RunSuperSub(ctx context.Context, flow *workflow.Flow) (err error)

RunSuperSub executes the mock handler.

func (*Mock) SubTaskA

func (svc *Mock) SubTaskA(ctx context.Context, flow *workflow.Flow) (err error)

SubTaskA executes the mock handler.

func (*Mock) SubTaskB

func (svc *Mock) SubTaskB(ctx context.Context, flow *workflow.Flow) (err error)

SubTaskB executes the mock handler.

func (*Mock) Super

func (svc *Mock) Super(ctx context.Context) (graph *workflow.Graph, err error)

Super returns the workflow graph, or a mocked graph if MockSuper was called.

func (*Mock) SuperSub

func (svc *Mock) SuperSub(ctx context.Context) (graph *workflow.Graph, err error)

SuperSub returns the workflow graph, or a mocked graph if MockSuperSub was called.

func (*Mock) TaskA

func (svc *Mock) TaskA(ctx context.Context, flow *workflow.Flow) (err error)

TaskA executes the mock handler.

func (*Mock) TaskB

func (svc *Mock) TaskB(ctx context.Context, flow *workflow.Flow) (err error)

TaskB executes the mock handler.

func (*Mock) TaskC

func (svc *Mock) TaskC(ctx context.Context, flow *workflow.Flow) (err error)

TaskC executes the mock handler.

func (*Mock) TaskD

func (svc *Mock) TaskD(ctx context.Context, flow *workflow.Flow) (err error)

TaskD executes the mock handler.

func (*Mock) TaskE

func (svc *Mock) TaskE(ctx context.Context, flow *workflow.Flow) (err error)

TaskE executes the mock handler.

func (*Mock) TaskZ

func (svc *Mock) TaskZ(ctx context.Context, flow *workflow.Flow) (err error)

TaskZ executes the mock handler.

type Service

type Service struct {
	*Intermediate // IMPORTANT: Do not remove
	// contains filtered or unexported fields
}

Service implements superflow.verify, a single fixture whose Super graph exercises every workflow transition primitive (sequential, forEach fan-out with fan-in, OnError with sibling-cancel, conditional, subgraph call, and goto). Per-task runtime behavior is injected through the workflow state under the Behaviors map, so a single graph can express many test cases.

func NewService

func NewService() *Service

NewService creates a new instance of the microservice.

func (*Service) AllVisits

func (svc *Service) AllVisits() map[string]int64

AllVisits returns a snapshot of every task's visit count.

func (*Service) ErrorHandler

func (svc *Service) ErrorHandler(ctx context.Context, flow *workflow.Flow) (err error)

ErrorHandler receives flows whose TaskC raised an error and rejoins the fan-in at TaskD so the workflow can still complete.

func (*Service) Init

func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service

Init enables a single-statement pattern for initializing the microservice.

func (*Service) OnShutdown

func (svc *Service) OnShutdown(ctx context.Context) (err error)

OnShutdown is called when the microservice is shut down.

func (*Service) OnStartup

func (svc *Service) OnStartup(ctx context.Context) (err error)

OnStartup is called when the microservice is started up.

func (*Service) ResetVisitCounters

func (svc *Service) ResetVisitCounters()

ResetVisitCounters zeroes every counter. Call between subtests sharing one service instance.

func (*Service) RunSuperSub added in v1.37.0

func (svc *Service) RunSuperSub(ctx context.Context, flow *workflow.Flow) (err error)

RunSuperSub invokes the SuperSub subgraph via flow.Subgraph. It is the conditional branch out of TaskD (when useSubgraph), converging at TaskE.

func (*Service) SubTaskA

func (svc *Service) SubTaskA(ctx context.Context, flow *workflow.Flow) (err error)

SubTaskA is the entry of the SuperSub subgraph.

func (*Service) SubTaskB

func (svc *Service) SubTaskB(ctx context.Context, flow *workflow.Flow) (err error)

SubTaskB is the second step of the SuperSub subgraph.

func (*Service) Super

func (svc *Service) Super(ctx context.Context) (graph *workflow.Graph, err error)

Super defines the unified verification graph. Coverage: - sequential transitions (A -> B) - dynamic fan-out via forEach (B -> C per items[i]) - OnError + sibling-cancel (C -> ErrorHandler) - explicit fan-in (TaskD) - conditional fan-out (TaskD's when branches) - subgraph call (TaskD -> SuperSubCall when useSubgraph) - conditional fan-in (TaskE) - withGoto (TaskE -> TaskZ when a prior task issued flow.Goto)

func (*Service) SuperSub

func (svc *Service) SuperSub(ctx context.Context) (graph *workflow.Graph, err error)

SuperSub is the nested subgraph: a minimal two-task sequence.

func (*Service) TaskA

func (svc *Service) TaskA(ctx context.Context, flow *workflow.Flow) (err error)

TaskA is the entry of the Super graph.

func (*Service) TaskB

func (svc *Service) TaskB(ctx context.Context, flow *workflow.Flow) (err error)

TaskB is the forEach source; its sole outgoing transition iterates items.

func (*Service) TaskC

func (svc *Service) TaskC(ctx context.Context, flow *workflow.Flow) (err error)

TaskC runs once per forEach element and converges into TaskD's fan-in.

func (*Service) TaskD

func (svc *Service) TaskD(ctx context.Context, flow *workflow.Flow) (err error)

TaskD is the forEach fan-in target. Its conditional outgoing transitions either invoke the SuperSub subgraph or jump straight to TaskE.

func (*Service) TaskE

func (svc *Service) TaskE(ctx context.Context, flow *workflow.Flow) (err error)

TaskE is the conditional fan-in target. Supports a goto to TaskZ.

func (*Service) TaskZ

func (svc *Service) TaskZ(ctx context.Context, flow *workflow.Flow) (err error)

TaskZ is the goto target out of TaskE.

func (*Service) Visits

func (svc *Service) Visits(name string) int64

Visits returns the number of times the named task has been entered since the last ResetVisitCounters. Returns 0 for unknown task names.

type ToDo

type ToDo interface {
	OnStartup(ctx context.Context) (err error)
	OnShutdown(ctx context.Context) (err error)
	TaskA(ctx context.Context, flow *workflow.Flow) (err error)        // MARKER: TaskA
	TaskB(ctx context.Context, flow *workflow.Flow) (err error)        // MARKER: TaskB
	TaskC(ctx context.Context, flow *workflow.Flow) (err error)        // MARKER: TaskC
	TaskD(ctx context.Context, flow *workflow.Flow) (err error)        // MARKER: TaskD
	TaskE(ctx context.Context, flow *workflow.Flow) (err error)        // MARKER: TaskE
	TaskZ(ctx context.Context, flow *workflow.Flow) (err error)        // MARKER: TaskZ
	ErrorHandler(ctx context.Context, flow *workflow.Flow) (err error) // MARKER: ErrorHandler
	SubTaskA(ctx context.Context, flow *workflow.Flow) (err error)     // MARKER: SubTaskA
	SubTaskB(ctx context.Context, flow *workflow.Flow) (err error)     // MARKER: SubTaskB
	RunSuperSub(ctx context.Context, flow *workflow.Flow) (err error)  // MARKER: RunSuperSub
	Super(ctx context.Context) (graph *workflow.Graph, err error)      // MARKER: Super
	SuperSub(ctx context.Context) (graph *workflow.Graph, err error)   // MARKER: SuperSub
}

ToDo is implemented by the service or mock.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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