Documentation
¶
Index ¶
- Constants
- type Intermediate
- type Mock
- func (svc *Mock) Flaky(ctx context.Context, flow *workflow.Flow, attempts int, target int) (attemptsOut int, err error)
- func (svc *Mock) MockFlaky(...) *Mock
- func (svc *Mock) MockRetry(...) *Mock
- func (svc *Mock) MockTaskA(...) *Mock
- func (svc *Mock) MockTaskB(...) *Mock
- func (svc *Mock) OnShutdown(ctx context.Context) (err error)
- func (svc *Mock) OnStartup(ctx context.Context) (err error)
- func (svc *Mock) Retry(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Mock) TaskA(ctx context.Context, flow *workflow.Flow, target int) (targetOut int, err error)
- func (svc *Mock) TaskB(ctx context.Context, flow *workflow.Flow, attempts int) (finalAttempts int, err error)
- type Service
- func (svc *Service) Flaky(ctx context.Context, flow *workflow.Flow, attempts, target int) (attemptsOut int, err error)
- func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service
- func (svc *Service) OnShutdown(ctx context.Context) (err error)
- func (svc *Service) OnStartup(ctx context.Context) (err error)
- func (svc *Service) Retry(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Service) TaskA(ctx context.Context, flow *workflow.Flow, target int) (targetOut int, err error)
- func (svc *Service) TaskB(ctx context.Context, flow *workflow.Flow, attempts int) (finalAttempts int, err error)
- type ToDo
Constants ¶
const ( Hostname = retryflowapi.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) Flaky ¶
func (svc *Mock) Flaky(ctx context.Context, flow *workflow.Flow, attempts int, target int) (attemptsOut int, err error)
Flaky executes the mock handler.
func (*Mock) MockFlaky ¶
func (svc *Mock) MockFlaky(handler func(ctx context.Context, flow *workflow.Flow, attempts int, target int) (attemptsOut int, err error)) *Mock
MockFlaky sets up a mock handler for Flaky.
func (*Mock) MockRetry ¶
func (svc *Mock) MockRetry(handler func(ctx context.Context, flow *workflow.Flow, target int) (finalAttempts int, err error)) *Mock
MockRetry sets up a mock handler for the Retry 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, target int) (targetOut int, 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, attempts int) (finalAttempts int, err error)) *Mock
MockTaskB sets up a mock handler for TaskB.
func (*Mock) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
type Service ¶
type Service struct {
*Intermediate // IMPORTANT: Do not remove
}
Service implements retryflow.verify, exercising flow.Retry.
func (*Service) Flaky ¶
func (svc *Service) Flaky(ctx context.Context, flow *workflow.Flow, attempts, target int) (attemptsOut int, err error)
Flaky increments attempts; if attempts<target, calls flow.Retry up to 5 attempts.
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, target int) (targetOut int, err error) // MARKER: TaskA
Flaky(ctx context.Context, flow *workflow.Flow, attempts, target int) (attemptsOut int, err error) // MARKER: Flaky
TaskB(ctx context.Context, flow *workflow.Flow, attempts int) (finalAttempts int, err error) // MARKER: TaskB
Retry(ctx context.Context) (graph *workflow.Graph, err error) // MARKER: Retry
}
ToDo is implemented by the service or mock.