adaptiveconcurrencyflow

package
v1.35.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Hostname = adaptiveconcurrencyflowapi.Hostname
	Version  = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Intermediate

type Intermediate struct {
	*connector.Connector
	ToDo
}

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 NewMock

func NewMock() *Mock

NewMock creates a new mockable version of the microservice.

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

func (svc *Mock) AdaptiveConcurrency(ctx context.Context) (graph *workflow.Graph, err error)

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

func (svc *Mock) OnShutdown(ctx context.Context) (err error)

OnShutdown is called when the microservice is shut down.

func (*Mock) OnStartup

func (svc *Mock) OnStartup(ctx context.Context) (err error)

OnStartup is called when the microservice is started up.

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 NewService

func NewService() *Service

NewService creates a new instance of the microservice.

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

func (svc *Service) AdaptiveConcurrency(ctx context.Context) (graph *workflow.Graph, err error)

AdaptiveConcurrency is a single-task graph routing through the rate-bounded Adaptive task.

func (*Service) Init

func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service

Init enables a single-statement pattern for initializing the microservice.

func (*Service) Observed

func (svc *Service) Observed() (completions, rejections int)

Observed returns the running counters (completions, rejections).

func (*Service) OnShutdown

func (svc *Service) OnShutdown(ctx context.Context) (err error)

OnShutdown is called when the microservice is shut down.

func (*Service) OnStartup

func (svc *Service) OnStartup(ctx context.Context) (err error)

OnStartup is called when the microservice is started up.

func (*Service) SetDwell

func (svc *Service) SetDwell(d time.Duration) *Service

SetDwell sets the per-invocation sleep duration.

func (*Service) SetRate

func (svc *Service) SetRate(rate int) *Service

SetRate configures the task's per-second admission rate. Must be called before app.RunInTest.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL