subgraphflow

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 = subgraphflowapi.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) 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, seed string) (innerResult string, 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) MockParent

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

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

func (*Mock) MockRunInner added in v1.37.0

func (svc *Mock) MockRunInner(handler func(ctx context.Context, flow *workflow.Flow, seed string) (innerResult string, err error)) *Mock

MockRunInner sets up a mock handler for RunInner.

func (*Mock) MockTaskA

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

MockTaskA sets up a mock handler for TaskA.

func (*Mock) MockTaskX

func (svc *Mock) MockTaskX(handler func(ctx context.Context, flow *workflow.Flow, seed string) (innerStage string, 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, innerStage string) (innerResult string, 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, innerResult string) (finalResult string, 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) Parent

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

Parent returns the workflow graph, or a mocked graph if MockParent was called.

func (*Mock) RunInner added in v1.37.0

func (svc *Mock) RunInner(ctx context.Context, flow *workflow.Flow, seed string) (innerResult string, err error)

RunInner executes the mock handler.

func (*Mock) TaskA

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

TaskA executes the mock handler.

func (*Mock) TaskX

func (svc *Mock) TaskX(ctx context.Context, flow *workflow.Flow, seed string) (innerStage string, err error)

TaskX executes the mock handler.

func (*Mock) TaskY

func (svc *Mock) TaskY(ctx context.Context, flow *workflow.Flow, innerStage string) (innerResult string, err error)

TaskY executes the mock handler.

func (*Mock) TaskZ

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

TaskZ executes the mock handler.

type Service

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

Service implements subgraphflow.verify, exercising subgraph invocation.

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. It declares `seed` as input and `innerResult` as output; the parent step's state crosses the boundary filtered through these.

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) (graph *workflow.Graph, err error)

Parent defines the graph A -> [Inner subgraph] -> Z.

func (*Service) RunInner added in v1.37.0

func (svc *Service) RunInner(ctx context.Context, flow *workflow.Flow, seed string) (innerResult string, err error)

RunInner invokes the Inner subgraph via flow.Subgraph and adopts its `innerResult` output into parent state. Parks on the first call, then re-runs with the child's result and returns it.

func (*Service) TaskA

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

TaskA passes the seed through.

func (*Service) TaskX

func (svc *Service) TaskX(ctx context.Context, flow *workflow.Flow, seed string) (innerStage string, err error)

TaskX is the subgraph entry. It reads `seed` and writes `innerStage`.

func (*Service) TaskY

func (svc *Service) TaskY(ctx context.Context, flow *workflow.Flow, innerStage string) (innerResult string, err error)

TaskY runs after TaskX in the subgraph. Reads `innerStage`, writes `innerResult`.

func (*Service) TaskZ

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

TaskZ runs in the parent after the subgraph. Reads `innerResult` (adopted from the subgraph by RunInner) and produces a final result.

type ToDo

type ToDo interface {
	OnStartup(ctx context.Context) (err error)
	OnShutdown(ctx context.Context) (err error)
	TaskA(ctx context.Context, flow *workflow.Flow, seed string) (seedOut string, err error)            // MARKER: TaskA
	TaskX(ctx context.Context, flow *workflow.Flow, seed string) (innerStage string, err error)         // MARKER: TaskX
	TaskY(ctx context.Context, flow *workflow.Flow, innerStage string) (innerResult string, err error)  // MARKER: TaskY
	TaskZ(ctx context.Context, flow *workflow.Flow, innerResult string) (finalResult string, err error) // MARKER: TaskZ
	RunInner(ctx context.Context, flow *workflow.Flow, seed string) (innerResult string, err error)     // MARKER: RunInner
	Inner(ctx context.Context) (graph *workflow.Graph, err error)                                       // MARKER: Inner
	Parent(ctx context.Context) (graph *workflow.Graph, err error)                                      // MARKER: Parent
}

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