Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrServiceOverloaded is returned by Shedder.Allow when the service is overloaded. ErrServiceOverloaded = errors.New("service overloaded") )
Functions ¶
Types ¶
type Promise ¶
type Promise interface { // Pass lets the caller tell that the call is successful. Pass() // Fail lets the caller tell that the call is failed. Fail() }
A Promise interface is returned by Shedder.Allow to let callers tell whether the processing request is successful or not.
type Shedder ¶
type Shedder interface { // Allow returns the Promise if allowed, otherwise ErrServiceOverloaded. Allow() (Promise, error) }
Shedder is the interface that wraps the Allow method.
func NewAdaptiveShedder ¶
func NewAdaptiveShedder(opts ...ShedderOption) Shedder
NewAdaptiveShedder returns an adaptive shedder. opts can be used to customize the Shedder.
type ShedderOption ¶
type ShedderOption func(opts *shedderOptions)
ShedderOption lets caller customize the Shedder.
func WithBuckets ¶
func WithBuckets(buckets int) ShedderOption
WithBuckets customizes the Shedder with given number of buckets.
func WithCpuThreshold ¶
func WithCpuThreshold(threshold float64) ShedderOption
WithCpuThreshold customizes the Shedder with given cpu threshold.
func WithWindow ¶
func WithWindow(window time.Duration) ShedderOption
WithWindow customizes the Shedder with given
Click to show internal directories.
Click to hide internal directories.