Versions in this module Expand all Collapse all v0 v0.1.1 Jul 31, 2026 v0.1.0 Jul 31, 2026 Changes in this version + func AttrValue(attrs []Attr, key string) (string, bool) + func Do[T any](ctx context.Context, controller *Controller, ...) (value T, err error) + type Attr struct + Key string + Value string + func AttrKey(key, value string) Attr + type Config struct + BucketCount int + DecayPerSecond float64 + Enabled bool + ErrorIncrease float64 + MaxPassPercent float64 + MinPassPercent float64 + MinSamples int64 + NeutralPolicy NeutralPolicy + OverloadIncrease float64 + PressureLimit float64 + SREK float64 + ShadowMode bool + Strategy StrategyType + SuccessDecrease float64 + Window time.Duration + func DefaultConfig() Config + type ConfigError struct + Issues []string + func (e ConfigError) Error() string + type ConfigProvider interface + Snapshot func() Config + type Controller struct + func New(name string, cfg Config, opts ...Option) *Controller + func (c *Controller) Acquire(ctx context.Context, attrs ...Attr) (Permit, Decision) + func (c *Controller) Allow(ctx context.Context, attrs ...Attr) Decision + func (c *Controller) Name() string + func (c *Controller) Report(outcome Outcome) + func (c *Controller) Snapshot() Snapshot + func (c *Controller) UpdateConfig(cfg Config) + type Decision struct + Allowed bool + DropRatio float64 + PassPercent float64 + Reason Reason + RetryAfter time.Duration + WouldReject bool + type ErrRejected struct + Decision Decision + func (e ErrRejected) Error() string + type KeySampler struct + Key string + func NewKeySampler(key string) *KeySampler + func (s *KeySampler) Allow(passPercent float64, attrs []Attr) bool + type MultiObserver []Observer + func (m MultiObserver) OnConfigError(name string, err error) + func (m MultiObserver) OnDecision(name string, decision Decision, attrs []Attr) + func (m MultiObserver) OnReport(name string, outcome Outcome, snapshot Snapshot, attrs []Attr) + type NeutralPolicy string + const NeutralCountsFailure + const NeutralCountsSuccess + const NeutralDoesNotAffect + type Observer interface + OnConfigError func(name string, err error) + OnDecision func(name string, decision Decision, attrs []Attr) + OnReport func(name string, outcome Outcome, snapshot Snapshot, attrs []Attr) + type ObserverFunc struct + ConfigError func(name string, err error) + Decision func(name string, decision Decision, attrs []Attr) + Report func(name string, outcome Outcome, snapshot Snapshot, attrs []Attr) + func (o ObserverFunc) OnConfigError(name string, err error) + func (o ObserverFunc) OnDecision(name string, decision Decision, attrs []Attr) + func (o ObserverFunc) OnReport(name string, outcome Outcome, snapshot Snapshot, attrs []Attr) + type Option func(*Controller) + func WithConfigProvider(provider ConfigProvider) Option + func WithObserver(observer Observer) Option + func WithSampler(sampler Sampler) Option + func WithStrategy(strategyType StrategyType, strategy Strategy) Option + type Outcome struct + Class OutcomeClass + Err error + Latency time.Duration + Weight float64 + func Failure(err error) Outcome + func Neutral() Outcome + func Overload(err error) Outcome + func Success() Outcome + func (o Outcome) WithLatency(latency time.Duration) Outcome + func (o Outcome) WithWeight(weight float64) Outcome + type OutcomeClass int + const OutcomeFailure + const OutcomeNeutral + const OutcomeOverload + const OutcomeSuccess + func (c OutcomeClass) String() string + type Permit interface + Report func(outcome Outcome) + type RandomSampler struct + func NewRandomSampler(seed uint64) *RandomSampler + func (s *RandomSampler) Allow(passPercent float64, _ []Attr) bool + type Reason string + const ReasonAdaptiveDrop + const ReasonAllowed + const ReasonDisabled + const ReasonInvalidConfig + const ReasonMaxPass + const ReasonMinSamples + const ReasonPressure + type Sampler interface + Allow func(passPercent float64, attrs []Attr) bool + type SequenceSampler struct + func NewSequenceSampler() *SequenceSampler + func (s *SequenceSampler) Allow(passPercent float64, _ []Attr) bool + type Snapshot struct + Config Config + DropRatio float64 + Enabled bool + LocalRejects int64 + Name string + PassPercent float64 + Pressure float64 + ShadowRejects int64 + Strategy StrategyType + UpdatedAt time.Time + WindowAccepts int64 + WindowFailures int64 + WindowRequests int64 + type StaticConfig struct + func NewStaticConfig(cfg Config) *StaticConfig + func (c *StaticConfig) Snapshot() Config + func (c *StaticConfig) Store(cfg Config) + type Strategy interface + Allow func(now time.Time, cfg Config, attrs []Attr) Decision + Report func(now time.Time, cfg Config, outcome Outcome, attrs []Attr) + Snapshot func(now time.Time, cfg Config) Snapshot + type StrategyType string + const StrategyPressure + const StrategySREAdaptive