nestedfanoutflow

package
v1.32.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

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

Inner returns the workflow graph, or a mocked graph if MockInner was called.

func (*Mock) MockInner

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

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

func (*Mock) MockNested

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

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

func (*Mock) MockNormalB

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

MockNormalB sets up a mock handler for NormalB.

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

func (svc *Mock) MockTaskJ(handler func(ctx context.Context, flow *workflow.Flow, normalResult string, innerResult int) (finalResult string, err error)) *Mock

MockTaskJ sets up a mock handler for TaskJ.

func (*Mock) MockTaskW

func (svc *Mock) MockTaskW(handler func(ctx context.Context, flow *workflow.Flow, sumInner int) (innerResult int, err error)) *Mock

MockTaskW sets up a mock handler for TaskW.

func (*Mock) MockTaskX

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

MockTaskX sets up a mock handler for TaskX.

func (*Mock) MockTaskY

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

MockTaskY sets up a mock handler for TaskY.

func (*Mock) MockTaskZ

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

MockTaskZ sets up a mock handler for TaskZ.

func (*Mock) Nested

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

Nested returns the workflow graph, or a mocked graph if MockNested was called.

func (*Mock) NormalB

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

NormalB executes the mock handler.

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

func (svc *Mock) TaskJ(ctx context.Context, flow *workflow.Flow, normalResult string, innerResult int) (finalResult string, err error)

TaskJ executes the mock handler.

func (*Mock) TaskW

func (svc *Mock) TaskW(ctx context.Context, flow *workflow.Flow, sumInner int) (innerResult int, err error)

TaskW executes the mock handler.

func (*Mock) TaskX

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

TaskX executes the mock handler.

func (*Mock) TaskY

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

TaskY executes the mock handler.

func (*Mock) TaskZ

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

TaskZ executes the mock handler.

type Service

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

Service implements nestedfanoutflow.verify, exercising two-level nested fan-out via the subgraph escape hatch.

func NewService

func NewService() *Service

NewService creates a new instance of the microservice.

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

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

Inner defines the subgraph X -> {Y, Z} -> W.

func (*Service) Nested

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

Nested defines the outer graph A -> {NormalB, Inner subgraph} -> J.

func (*Service) NormalB

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

NormalB is the non-subgraph sibling of the outer fan-out.

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 outer fan-out source.

func (*Service) TaskJ

func (svc *Service) TaskJ(ctx context.Context, flow *workflow.Flow, normalResult string, innerResult int) (finalResult string, err error)

TaskJ is the outer fan-in; combines NormalB's result with the inner subgraph's result.

func (*Service) TaskW

func (svc *Service) TaskW(ctx context.Context, flow *workflow.Flow, sumInner int) (innerResult int, err error)

TaskW is the inner subgraph fan-in; reads the merged sumInner.

func (*Service) TaskX

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

TaskX is the inner subgraph entry.

func (*Service) TaskY

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

TaskY contributes +10 to the inner sum reducer.

func (*Service) TaskZ

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

TaskZ contributes +20 to the inner sum reducer.

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
	NormalB(ctx context.Context, flow *workflow.Flow) (normalResult string, err error)                                    // MARKER: NormalB
	TaskX(ctx context.Context, flow *workflow.Flow) (innerStarted bool, err error)                                        // MARKER: TaskX
	TaskY(ctx context.Context, flow *workflow.Flow) (sumInnerOut int, err error)                                          // MARKER: TaskY
	TaskZ(ctx context.Context, flow *workflow.Flow) (sumInnerOut int, err error)                                          // MARKER: TaskZ
	TaskW(ctx context.Context, flow *workflow.Flow, sumInner int) (innerResult int, err error)                            // MARKER: TaskW
	TaskJ(ctx context.Context, flow *workflow.Flow, normalResult string, innerResult int) (finalResult string, err error) // MARKER: TaskJ
	Inner(ctx context.Context) (graph *workflow.Graph, err error)                                                         // MARKER: Inner
	Nested(ctx context.Context) (graph *workflow.Graph, err error)                                                        // MARKER: Nested
}

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