Documentation
¶
Index ¶
- Constants
- type Intermediate
- type Mock
- func (svc *Mock) Adaptive(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)
- func (svc *Mock) AdaptiveConcurrency(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Mock) MockAdaptive(...) *Mock
- func (svc *Mock) MockAdaptiveConcurrency(...) *Mock
- func (svc *Mock) OnShutdown(ctx context.Context) (err error)
- func (svc *Mock) OnStartup(ctx context.Context) (err error)
- type Service
- func (svc *Service) Adaptive(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)
- func (svc *Service) AdaptiveConcurrency(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service
- func (svc *Service) Observed() (completions, rejections int)
- func (svc *Service) OnShutdown(ctx context.Context) (err error)
- func (svc *Service) OnStartup(ctx context.Context) (err error)
- func (svc *Service) SetDwell(d time.Duration) *Service
- func (svc *Service) SetRate(rate int) *Service
- type ToDo
Constants ¶
const ( Hostname = adaptiveconcurrencyflowapi.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) Adaptive ¶
func (svc *Mock) Adaptive(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)
Adaptive executes the mock handler.
func (*Mock) AdaptiveConcurrency ¶
AdaptiveConcurrency returns the workflow graph, or a mocked graph if MockAdaptiveConcurrency was called.
func (*Mock) MockAdaptive ¶
func (svc *Mock) MockAdaptive(handler func(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)) *Mock
MockAdaptive sets up a mock handler for Adaptive.
func (*Mock) MockAdaptiveConcurrency ¶
func (svc *Mock) MockAdaptiveConcurrency(handler func(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)) *Mock
MockAdaptiveConcurrency sets up a mock handler for the AdaptiveConcurrency 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 adaptiveconcurrencyflow.verify, exercising the foreman's rate controller against a rate-bounded backend. The task admits up to a configurable ops/sec and emits 429 above that.
func (*Service) Adaptive ¶
func (svc *Service) Adaptive(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)
Adaptive is gated by an internal sliding-window throttle. Returns 429 when the per-second budget is exhausted; otherwise sleeps dwell, increments the completions counter, and returns.
func (*Service) AdaptiveConcurrency ¶
AdaptiveConcurrency is a single-task graph routing through the rate-bounded Adaptive task.
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)
Adaptive(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error) // MARKER: Adaptive
AdaptiveConcurrency(ctx context.Context) (graph *workflow.Graph, err error) // MARKER: AdaptiveConcurrency
}
ToDo is implemented by the service or mock.