adaptive

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package adaptive implements bounded, request-driven feedback control.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adjustment

type Adjustment struct {
	Profile, ControlPriority             string
	ControlRatio, ControlFailureFraction float64
	Previous, Limit, Samples             int
	Reason                               string
	P90Ratio                             float64
}

type Config

type Config struct {
	Profile              string
	Min, Max, MinSamples int
	Interval             time.Duration
}

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func New

func New(limiter *admission.Limiter, c Config) *Controller

func (*Controller) Begin

func (c *Controller) Begin(priority admission.Priority, now time.Time) (admission.Decision, uint64)

Begin coordinates the admission decision and measurement generation. There is no capacity wait. Total/background saturation can justify cautious growth.

func (*Controller) BeginBudget added in v0.6.0

func (c *Controller) BeginBudget(priority admission.Priority, now time.Time, bucket, buckets, ceiling int) (admission.Decision, uint64)

func (*Controller) BeginCohort added in v0.4.0

func (c *Controller) BeginCohort(priority admission.Priority, now time.Time, bucket, buckets int) (admission.Decision, uint64)

func (*Controller) End

func (c *Controller) End(priority admission.Priority, generation uint64, now time.Time, elapsed, target time.Duration, failed, canceled bool) *Adjustment

End always releases admitted work, including canceled/stale-generation work. Only current, noncanceled completions contribute feedback. Timings are divided by each handler's configured latency budget before aggregation.

func (*Controller) Snapshot added in v0.2.0

func (c *Controller) Snapshot() Evaluation

Snapshot does not evaluate or reset the controller. A zero timestamp means no eligible ordinary or sparse window has been evaluated yet.

type Evaluation added in v0.2.0

type Evaluation struct {
	ControlRatio, ControlFailureFraction          float64
	ControlPriority                               string
	Profile                                       string
	SmoothedControlRatio                          float64
	SparseWindow, ExternalLimit                   bool
	PressureStreak, HealthyStreak, PendingSamples int
	WindowStartedAt                               time.Time
	WindowInterval                                time.Duration
	EvaluatedAt                                   time.Time
	Samples                                       int
	P90Ratio, FailureFraction                     float64
	PreviousLimit, Limit                          int
	Saturated                                     bool
	Decision, Reason                              string
}

Evaluation describes the last completed feedback window, including hold decisions.

Jump to

Keyboard shortcuts

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