Documentation
¶
Overview ¶
Package decision combines cached overload observations into bounded admission proposals. It never samples a provider or makes a network call during Evaluate.
Index ¶
- Variables
- func ValidName(s string) bool
- func WithResult(ctx context.Context, r Result) context.Context
- type Assessment
- type Collector
- type Config
- type Effect
- type Engine
- func (e *Engine) Evaluate(target Target, baseline int, now time.Time) Evaluation
- func (e *Engine) HasActorRules() bool
- func (e *Engine) Mode() Mode
- func (e *Engine) Publish(name string, o Observation) error
- func (e *Engine) Run(ctx context.Context, collectors []Collector) error
- func (e *Engine) Snapshot() []SignalSnapshot
- func (e *Engine) Unavailable(name string) error
- func (e *Engine) ValidateCollectors(collectors []Collector) error
- type Evaluation
- type HTTPProvider
- type Mode
- type Observation
- type Provider
- type ProviderFunc
- type Result
- type Rule
- type Scope
- type SignalSnapshot
- type Stage
- type Target
Constants ¶
This section is empty.
Variables ¶
var ErrFutureObservation = errors.New("decision: future observation")
var ErrInvalidObservation = errors.New("decision: invalid observation")
var ErrOutOfOrder = errors.New("decision: out-of-order observation")
Functions ¶
Types ¶
type Assessment ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) HasActorRules ¶
func (*Engine) Run ¶
Run owns background sampling until cancellation. At most one sample per signal can be in flight, including across Run restarts. A provider that ignores its context can leave one worker blocked; it cannot create unbounded replacement workers.
func (*Engine) Snapshot ¶
func (e *Engine) Snapshot() []SignalSnapshot
func (*Engine) Unavailable ¶
Unavailable publishes a current unknown state, never the provider's error text.
func (*Engine) ValidateCollectors ¶
type Evaluation ¶
type Evaluation struct {
Mode Mode
BaselineLimit, ProposedLimit, EffectiveLimit int
SignalCeiling int // Smallest matching raw cap; independent of a moving adaptive baseline.
Action, Reason string
Reject bool // Enforced explicit rejection. A cap is checked atomically later.
Assessments []Assessment
}
type HTTPProvider ¶
type HTTPProvider struct {
// contains filtered or unexported fields
}
func NewHTTPProvider ¶
func NewHTTPProvider(address string) (*HTTPProvider, error)
NewHTTPProvider reads a small observation document from an operator-selected endpoint. It disables redirects/environment proxies and validates TLS normally.
func (*HTTPProvider) Close ¶
func (p *HTTPProvider) Close()
func (*HTTPProvider) Sample ¶
func (p *HTTPProvider) Sample(ctx context.Context) (Observation, error)
type Observation ¶
type Observation struct {
Value float64 `json:"value"`
ObservedAt time.Time `json:"observed_at"`
State string `json:"state"`
}
Observation timestamps describe measurement time, not delivery time. Unknown explicitly invalidates an earlier value. Duplicate timestamps never renew age.
type ProviderFunc ¶
type ProviderFunc func(context.Context) (Observation, error)
func (ProviderFunc) Sample ¶
func (f ProviderFunc) Sample(ctx context.Context) (Observation, error)
type Result ¶
type Result struct {
Allowed bool
Priority, Resource, Reason, Stage string
Evaluation Evaluation
Stages []Stage
}
type SignalSnapshot ¶
type SignalSnapshot struct {
Assessment
Accepted uint64
Dropped [3]uint64
Failures [4]uint64
Collecting bool
}