gotoflow

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Hostname = gotoflowapi.Hostname
	Version  = 1
)

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) BadGoto

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

BadGoto returns the workflow graph, or a mocked graph if MockBadGoto was called.

func (*Mock) BadGotoer

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

BadGotoer executes the mock handler.

func (*Mock) Goto

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

Goto returns the workflow graph, or a mocked graph if MockGoto was called.

func (*Mock) MockBadGoto

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

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

func (*Mock) MockBadGotoer

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

MockBadGotoer sets up a mock handler for BadGotoer.

func (*Mock) MockGoto

func (svc *Mock) MockGoto(handler func(ctx context.Context, flow *workflow.Flow, target int) (finalLoops int, err error)) *Mock

MockGoto sets up a mock handler for the Goto 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, loops int) (loopsOut int, 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, loops int, target int) (visited bool, 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, loops int) (finalLoops int, err error)) *Mock

MockTaskC sets up a mock handler for TaskC.

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) TaskA

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

TaskA executes the mock handler.

func (*Mock) TaskB

func (svc *Mock) TaskB(ctx context.Context, flow *workflow.Flow, loops int, target int) (visited bool, err error)

TaskB executes the mock handler.

func (*Mock) TaskC

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

TaskC executes the mock handler.

type Service

type Service struct {
	*Intermediate // IMPORTANT: Do not remove
}

Service implements gotoflow.verify, exercising flow.Goto and AddTransitionGoto.

func NewService

func NewService() *Service

NewService creates a new instance of the microservice.

func (*Service) BadGoto

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

BadGoto defines a single-task graph whose only task issues an unregistered Goto. The flow must end with status=failed.

func (*Service) BadGotoer

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

BadGotoer requests a goto to a target that has no AddTransitionGoto registered for it. The foreman surfaces the unregistered target as a step failure.

func (*Service) Goto

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

Goto defines the graph A -> B -> C with B -> withGoto -> A.

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) TaskA

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

TaskA increments the loops counter.

func (*Service) TaskB

func (svc *Service) TaskB(ctx context.Context, flow *workflow.Flow, loops int, target int) (visited bool, err error)

TaskB calls flow.Goto(TaskA) until the loop counter reaches target, then falls through.

func (*Service) TaskC

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

TaskC surfaces the final loops count.

type ToDo

type ToDo interface {
	OnStartup(ctx context.Context) (err error)
	OnShutdown(ctx context.Context) (err error)
	TaskA(ctx context.Context, flow *workflow.Flow, loops int) (loopsOut int, err error)         // MARKER: TaskA
	TaskB(ctx context.Context, flow *workflow.Flow, loops, target int) (visited bool, err error) // MARKER: TaskB
	TaskC(ctx context.Context, flow *workflow.Flow, loops int) (finalLoops int, err error)       // MARKER: TaskC
	BadGotoer(ctx context.Context, flow *workflow.Flow) (stamp bool, err error)                  // MARKER: BadGotoer
	Goto(ctx context.Context) (graph *workflow.Graph, err error)                                 // MARKER: Goto
	BadGoto(ctx context.Context) (graph *workflow.Graph, err error)                              // MARKER: BadGoto
}

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