Documentation
¶
Index ¶
- Constants
- type Intermediate
- type Mock
- func (svc *Mock) AwaitInput(ctx context.Context, flow *workflow.Flow, userInput string) (userInputOut string, err error)
- func (svc *Mock) Compose(ctx context.Context, flow *workflow.Flow, prompt string, userInput string) (result string, err error)
- func (svc *Mock) Interruptor(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Mock) MockAwaitInput(...) *Mock
- func (svc *Mock) MockCompose(...) *Mock
- func (svc *Mock) MockInterruptor(...) *Mock
- func (svc *Mock) MockTaskA(...) *Mock
- func (svc *Mock) OnShutdown(ctx context.Context) (err error)
- func (svc *Mock) OnStartup(ctx context.Context) (err error)
- func (svc *Mock) TaskA(ctx context.Context, flow *workflow.Flow, prompt string) (promptOut string, err error)
- type Service
- func (svc *Service) AwaitInput(ctx context.Context, flow *workflow.Flow, userInput string) (userInputOut string, err error)
- func (svc *Service) Compose(ctx context.Context, flow *workflow.Flow, prompt, userInput string) (result string, err error)
- func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service
- func (svc *Service) Interruptor(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Service) OnShutdown(ctx context.Context) (err error)
- func (svc *Service) OnStartup(ctx context.Context) (err error)
- func (svc *Service) TaskA(ctx context.Context, flow *workflow.Flow, prompt string) (promptOut string, err error)
- type ToDo
Constants ¶
const ( Hostname = interruptflowapi.Hostname Version = 1 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Intermediate ¶
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 (*Mock) AwaitInput ¶
func (svc *Mock) AwaitInput(ctx context.Context, flow *workflow.Flow, userInput string) (userInputOut string, err error)
AwaitInput executes the mock handler.
func (*Mock) Compose ¶
func (svc *Mock) Compose(ctx context.Context, flow *workflow.Flow, prompt string, userInput string) (result string, err error)
Compose executes the mock handler.
func (*Mock) Interruptor ¶
Interruptor returns the workflow graph, or a mocked graph if MockInterruptor was called.
func (*Mock) MockAwaitInput ¶
func (svc *Mock) MockAwaitInput(handler func(ctx context.Context, flow *workflow.Flow, userInput string) (userInputOut string, err error)) *Mock
MockAwaitInput sets up a mock handler for AwaitInput.
func (*Mock) MockCompose ¶
func (svc *Mock) MockCompose(handler func(ctx context.Context, flow *workflow.Flow, prompt string, userInput string) (result string, err error)) *Mock
MockCompose sets up a mock handler for Compose.
func (*Mock) MockInterruptor ¶
func (svc *Mock) MockInterruptor(handler func(ctx context.Context, flow *workflow.Flow, prompt string) (result string, err error)) *Mock
MockInterruptor sets up a mock handler for the Interruptor 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, prompt string) (promptOut string, err error)) *Mock
MockTaskA sets up a mock handler for TaskA.
func (*Mock) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
type Service ¶
type Service struct {
*Intermediate // IMPORTANT: Do not remove
}
Service implements interruptflow.verify, exercising flow.Interrupt + Resume.
func (*Service) AwaitInput ¶
func (svc *Service) AwaitInput(ctx context.Context, flow *workflow.Flow, userInput string) (userInputOut string, err error)
AwaitInput interrupts the flow until userInput is provided via Resume. On the re-execution after Resume, flow.Interrupt returns the resume data and the task surfaces userInput as its output.
func (*Service) Compose ¶
func (svc *Service) Compose(ctx context.Context, flow *workflow.Flow, prompt, userInput string) (result string, err error)
Compose joins prompt and userInput into the final result.
func (*Service) Interruptor ¶
Interruptor defines the graph A -> AwaitInput -> Compose.
func (*Service) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
type ToDo ¶
type ToDo interface {
OnStartup(ctx context.Context) (err error)
OnShutdown(ctx context.Context) (err error)
TaskA(ctx context.Context, flow *workflow.Flow, prompt string) (promptOut string, err error) // MARKER: TaskA
AwaitInput(ctx context.Context, flow *workflow.Flow, userInput string) (userInputOut string, err error) // MARKER: AwaitInput
Compose(ctx context.Context, flow *workflow.Flow, prompt, userInput string) (result string, err error) // MARKER: Compose
Interruptor(ctx context.Context) (graph *workflow.Graph, err error) // MARKER: Interruptor
}
ToDo is implemented by the service or mock.