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) MaxConcurrency(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Mock) MockBounded(...) *Mock
- func (svc *Mock) MockMaxConcurrency(...) *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) Init(initializer func(svc *Service) (err error)) *Service
- func (svc *Service) MaxConcurrency(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Service) Observed() (peak int, rejections 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 = maxconcurrencyflowapi.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) MaxConcurrency ¶
MaxConcurrency returns the workflow graph, or a mocked graph if MockMaxConcurrency 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) MockMaxConcurrency ¶
func (svc *Mock) MockMaxConcurrency(handler func(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)) *Mock
MockMaxConcurrency sets up a mock handler for the MaxConcurrency 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 maxconcurrencyflow.verify, exercising adaptive per-task concurrency control via a task that self-emits 429 above a configured cap.
func (*Service) Bounded ¶
func (svc *Service) Bounded(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)
Bounded admits up to cap concurrent in-flight executions. Above that it returns http.StatusTooManyRequests so the foreman observes a 429 and exercises its backpressure path. While admitted, the task sleeps to overlap with peers.
func (*Service) MaxConcurrency ¶
MaxConcurrency defines the single-task graph (bounded -> END) used to drive the foreman through the backpressure path.
func (*Service) Observed ¶
Observed returns (peak in-flight observed, total 429 rejections emitted).
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
MaxConcurrency(ctx context.Context) (graph *workflow.Graph, err error) // MARKER: MaxConcurrency
}
ToDo is implemented by the service or mock.