dynamicsubgraphflow

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

Documentation

Index

Constants

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

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

DynamicSubgraph returns the workflow graph, or a mocked graph if MockDynamicSubgraph was called.

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

func (svc *Mock) InnerA(ctx context.Context, flow *workflow.Flow, value int) (innerStage int, err error)

InnerA executes the mock handler.

func (*Mock) InnerB

func (svc *Mock) InnerB(ctx context.Context, flow *workflow.Flow, innerStage int) (innerResult int, innerDone bool, err error)

InnerB executes the mock handler.

func (*Mock) MockDynamicSubgraph

func (svc *Mock) MockDynamicSubgraph(handler func(ctx context.Context, flow *workflow.Flow, value int) (parentResult string, err error)) *Mock

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

func (*Mock) MockInner

func (svc *Mock) MockInner(handler func(ctx context.Context, flow *workflow.Flow, value int) (innerResult int, innerDone bool, 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) MockInnerA

func (svc *Mock) MockInnerA(handler func(ctx context.Context, flow *workflow.Flow, value int) (innerStage int, err error)) *Mock

MockInnerA sets up a mock handler for InnerA.

func (*Mock) MockInnerB

func (svc *Mock) MockInnerB(handler func(ctx context.Context, flow *workflow.Flow, innerStage int) (innerResult int, innerDone bool, err error)) *Mock

MockInnerB sets up a mock handler for InnerB.

func (*Mock) MockParent

func (svc *Mock) MockParent(handler func(ctx context.Context, flow *workflow.Flow, value int, innerDone bool, innerResult int) (parentResult string, err error)) *Mock

MockParent sets up a mock handler for Parent.

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

func (svc *Mock) Parent(ctx context.Context, flow *workflow.Flow, value int, innerDone bool, innerResult int) (parentResult string, err error)

Parent executes the mock handler.

type Service

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

Service implements dynamicsubgraphflow.verify, exercising the flow.Subgraph control signal.

func NewService

func NewService() *Service

NewService creates a new instance of the microservice.

func (*Service) DynamicSubgraph

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

DynamicSubgraph defines a single-task parent graph that dynamically invokes Inner.

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 child subgraph InnerA -> InnerB.

func (*Service) InnerA

func (svc *Service) InnerA(ctx context.Context, flow *workflow.Flow, value int) (innerStage int, err error)

InnerA doubles value.

func (*Service) InnerB

func (svc *Service) InnerB(ctx context.Context, flow *workflow.Flow, innerStage int) (innerResult int, innerDone bool, err error)

InnerB adds 3 to innerStage and marks the inner subgraph done.

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

func (svc *Service) Parent(ctx context.Context, flow *workflow.Flow, value int, innerDone bool, innerResult int) (parentResult string, err error)

Parent calls flow.Subgraph on its first invocation, then re-runs after the child completes with the child's outputs (innerDone, innerResult) merged into state.

type ToDo

type ToDo interface {
	OnStartup(ctx context.Context) (err error)
	OnShutdown(ctx context.Context) (err error)
	Parent(ctx context.Context, flow *workflow.Flow, value int, innerDone bool, innerResult int) (parentResult string, err error) // MARKER: Parent
	InnerA(ctx context.Context, flow *workflow.Flow, value int) (innerStage int, err error)                                       // MARKER: InnerA
	InnerB(ctx context.Context, flow *workflow.Flow, innerStage int) (innerResult int, innerDone bool, err error)                 // MARKER: InnerB
	Inner(ctx context.Context) (graph *workflow.Graph, err error)                                                                 // MARKER: Inner
	DynamicSubgraph(ctx context.Context) (graph *workflow.Graph, err error)                                                       // MARKER: DynamicSubgraph
}

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