Versions in this module Expand all Collapse all v0 v0.1.0 Dec 5, 2021 Changes in this version + var ErrLoadRequestRejected = &LoadRequestRejected + var ErrLoadRequestTimeout = &LoadRequestTimeout + type CompositeConfig struct + Limiters []Config + Logger Logger + SleepFunc func(d time.Duration) + SyncAdapter SyncAdapter + TimeFunc func() time.Time + type CompositeLoadLimiter interface + AsSingleTenant func() SingleTenantCompositeLoadLimiter + ForTenant func(tenantKey string) SingleTenantCompositeLoadLimiter + IsComposite func() bool + Probe func(tenantKey string, load uint64) (bool, error) + Stats func(tenantKey string) (CompositeRuntimeStatistics, error) + Submit func(tenantKey string, load uint64) (SubmitResult, error) + SubmitUntil func(tenantKey string, load uint64, timeout time.Duration) error + SubmitUntilWithDetails func(tenantKey string, load uint64, timeout time.Duration) SubmitUntilResult + func NewComposite(config *CompositeConfig) (CompositeLoadLimiter, error) + type CompositeRuntimeStatistics struct + LimitersStats []RuntimeStatistics + type Config struct + Logger Logger + MaxLoad uint64 + MaxPenaltyCapFactor float64 + OverstepPenaltyDistributionFactor float64 + OverstepPenaltyFactor float64 + RequestOverheadPenaltyDistributionFactor float64 + RequestOverheadPenaltyFactor float64 + SkipRetryInComputing bool + SleepFunc func(d time.Duration) + SyncAdapter SyncAdapter + TimeFunc func() time.Time + WindowSegmentSize time.Duration + WindowSize time.Duration + type LoadLimiter interface + IsComposite func() bool + Probe func(tenantKey string, load uint64) (bool, error) + Submit func(tenantKey string, load uint64) (SubmitResult, error) + SubmitUntil func(tenantKey string, load uint64, timeout time.Duration) error + SubmitUntilWithDetails func(tenantKey string, load uint64, timeout time.Duration) SubmitUntilResult + type LoadRequestRejected struct + Reason string + func (e *LoadRequestRejected) Error() string + func (e *LoadRequestRejected) Is(tgt error) bool + type LoadRequestTimeout struct + AttemptsNumber uint64 + WaitedFor time.Duration + func (e *LoadRequestTimeout) Error() string + func (e *LoadRequestTimeout) Is(tgt error) bool + type Logger interface + Debug func(string) + Error func(string) + Info func(string) + Warning func(string) + func NewNoOpLogger() Logger + type RuntimeStatistics struct + WindowSegments []uint64 + WindowTotal uint64 + type SingleTenantCompositeLoadLimiter interface + IsComposite func() bool + Probe func(load uint64) (bool, error) + Stats func() (CompositeRuntimeStatistics, error) + Submit func(load uint64) (SubmitResult, error) + SubmitUntil func(load uint64, timeout time.Duration) error + SubmitUntilWithDetails func(load uint64, timeout time.Duration) SubmitUntilResult + type SingleTenantLoadLimiter interface + IsComposite func() bool + Probe func(load uint64) (bool, error) + Submit func(load uint64) (SubmitResult, error) + SubmitUntil func(load uint64, timeout time.Duration) error + SubmitUntilWithDetails func(load uint64, timeout time.Duration) SubmitUntilResult + type SingleTenantStandaloneLoadLimiter interface + IsComposite func() bool + Probe func(load uint64) (bool, error) + Stats func() (RuntimeStatistics, error) + Submit func(load uint64) (SubmitResult, error) + SubmitUntil func(load uint64, timeout time.Duration) error + SubmitUntilWithDetails func(load uint64, timeout time.Duration) SubmitUntilResult + type StandaloneLoadLimiter interface + AsSingleTenant func() SingleTenantStandaloneLoadLimiter + ForTenant func(tenantKey string) SingleTenantStandaloneLoadLimiter + IsComposite func() bool + Probe func(tenantKey string, load uint64) (bool, error) + Stats func(tenantKey string) (RuntimeStatistics, error) + Submit func(tenantKey string, load uint64) (SubmitResult, error) + SubmitUntil func(tenantKey string, load uint64, timeout time.Duration) error + SubmitUntilWithDetails func(tenantKey string, load uint64, timeout time.Duration) SubmitUntilResult + func New(config *Config) (StandaloneLoadLimiter, error) + type SubmitResult struct + Accepted bool + RetryIn time.Duration + RetryInAvailable bool + func (s *SubmitResult) String() string + type SubmitUntilResult struct + AttemptsNumber uint64 + Error error + WaitedFor time.Duration + type SyncAdapter interface + Fetch func(ctx context.Context, tenantKey string) (string, error) + Lock func(ctx context.Context, tenantKey string) error + Unlock func(ctx context.Context, tenantKey string) error + Write func(ctx context.Context, tenantKey string, serializedData string) error