Documentation
¶
Index ¶
- Constants
- type Intermediate
- type Mock
- func (svc *Mock) Bounded(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)
- func (svc *Mock) DistributedBackpressure(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Mock) MockBounded(...) *Mock
- func (svc *Mock) MockDistributedBackpressure(...) *Mock
- func (svc *Mock) OnShutdown(ctx context.Context) (err error)
- func (svc *Mock) OnStartup(ctx context.Context) (err error)
- type Service
- func (svc *Service) Bounded(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)
- func (svc *Service) DistributedBackpressure(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service
- func (svc *Service) Observed() (peak int, rejections int, completions int)
- func (svc *Service) OnShutdown(ctx context.Context) (err error)
- func (svc *Service) OnStartup(ctx context.Context) (err error)
- func (svc *Service) SetCap(cap int) *Service
- func (svc *Service) SetDwell(d time.Duration) *Service
- type ToDo
Constants ¶
const ( Hostname = distributedbackpressureflowapi.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) Bounded ¶
func (svc *Mock) Bounded(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)
Bounded executes the mock handler.
func (*Mock) DistributedBackpressure ¶
DistributedBackpressure returns the workflow graph, or a mocked graph if MockDistributedBackpressure was called.
func (*Mock) MockBounded ¶
func (svc *Mock) MockBounded(handler func(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)) *Mock
MockBounded sets up a mock handler for Bounded.
func (*Mock) MockDistributedBackpressure ¶
func (svc *Mock) MockDistributedBackpressure(handler func(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)) *Mock
MockDistributedBackpressure sets up a mock handler for the DistributedBackpressure workflow. The handler receives typed inputs from the workflow's state and returns typed outputs. A nil handler clears the mock.
func (*Mock) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
type Service ¶
type Service struct {
*Intermediate // IMPORTANT: Do not remove
// contains filtered or unexported fields
}
Service implements distributedbackpressureflow.verify, exercising adaptive concurrency under multi-replica and multi-shard deployment.
func (*Service) Bounded ¶
func (svc *Service) Bounded(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)
Bounded self-emits http.StatusTooManyRequests above its cap. Both replicas of this fixture share the same Service singleton (registered once in the test app), so the cap is genuinely cluster-wide.
func (*Service) DistributedBackpressure ¶
DistributedBackpressure is a single-task graph routing through Bounded.
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)
Bounded(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error) // MARKER: Bounded
DistributedBackpressure(ctx context.Context) (graph *workflow.Graph, err error) // MARKER: DistributedBackpressure
}
ToDo is implemented by the service or mock.