onerrorsiblingsflow

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: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Hostname = onerrorsiblingsflowapi.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) FanOutError

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

FanOutError returns the workflow graph, or a mocked graph if MockFanOutError was called.

func (*Mock) Handler

func (svc *Mock) Handler(ctx context.Context, flow *workflow.Flow, onErr *errors.TracedError) (handled bool, err error)

Handler executes the mock handler.

func (*Mock) MockFanOutError

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

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

func (*Mock) MockHandler

func (svc *Mock) MockHandler(handler func(ctx context.Context, flow *workflow.Flow, onErr *errors.TracedError) (handled bool, err error)) *Mock

MockHandler sets up a mock handler for Handler.

func (*Mock) MockTaskA

func (svc *Mock) MockTaskA(handler func(ctx context.Context, flow *workflow.Flow) (started bool, 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, started bool) (markB 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, started bool) (markC bool, 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, started bool) (markD bool, 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, handled bool, markB bool, markC bool, markD bool) (recovered, siblingsRan bool, err error)) *Mock

MockTaskE sets up a mock handler for TaskE.

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) (started bool, err error)

TaskA executes the mock handler.

func (*Mock) TaskB

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

TaskB executes the mock handler.

func (*Mock) TaskC

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

TaskC executes the mock handler.

func (*Mock) TaskD

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

TaskD executes the mock handler.

func (*Mock) TaskE

func (svc *Mock) TaskE(ctx context.Context, flow *workflow.Flow, handled bool, markB bool, markC bool, markD bool) (recovered, siblingsRan bool, err error)

TaskE executes the mock handler.

type Service

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

Service implements onerrorsiblingsflow.verify, exercising OnError + fan-out.

func NewService

func NewService() *Service

NewService creates a new instance of the microservice.

func (*Service) FanOutError

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

FanOutError defines the graph A -> {B, C, D} -> E with B onError -> Handler -> E.

func (*Service) Handler

func (svc *Service) Handler(ctx context.Context, flow *workflow.Flow, onErr *errors.TracedError) (handled bool, err error)

Handler handles TaskB's error and sets handled=true.

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) (started bool, err error)

TaskA is the fan-out source. Marks the flow as started.

func (*Service) TaskB

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

TaskB always errors, triggering its onError transition.

func (*Service) TaskC

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

TaskC is a normal sibling that runs in parallel with TaskB.

func (*Service) TaskD

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

TaskD is a normal sibling that runs in parallel with TaskB.

func (*Service) TaskE

func (svc *Service) TaskE(ctx context.Context, flow *workflow.Flow, handled, markB, markC, markD bool) (recovered, siblingsRan bool, err error)

TaskE is the fan-in target. It surfaces two booleans:

  • recovered: the handler ran (handled=true) and TaskB never set markB.
  • siblingsRan: TaskC and TaskD both ran to completion (not cancelled).

type ToDo

type ToDo interface {
	OnStartup(ctx context.Context) (err error)
	OnShutdown(ctx context.Context) (err error)
	TaskA(ctx context.Context, flow *workflow.Flow) (started bool, err error)                                                   // MARKER: TaskA
	TaskB(ctx context.Context, flow *workflow.Flow, started bool) (markB bool, err error)                                       // MARKER: TaskB
	TaskC(ctx context.Context, flow *workflow.Flow, started bool) (markC bool, err error)                                       // MARKER: TaskC
	TaskD(ctx context.Context, flow *workflow.Flow, started bool) (markD bool, err error)                                       // MARKER: TaskD
	Handler(ctx context.Context, flow *workflow.Flow, onErr *errors.TracedError) (handled bool, err error)                      // MARKER: Handler
	TaskE(ctx context.Context, flow *workflow.Flow, handled, markB, markC, markD bool) (recovered, siblingsRan bool, err error) // MARKER: TaskE
	FanOutError(ctx context.Context) (graph *workflow.Graph, err error)                                                         // MARKER: FanOutError
}

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