Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockingLimiter ¶
type BlockingLimiter struct {
// contains filtered or unexported fields
}
BlockingLimiter implements a Limiter that blocks the caller when the limit has been reached. The caller is blocked until the limiter has been released. This limiter is commonly used in batch clients that use the limiter as a back-pressure mechanism.
func NewBlockingLimiter ¶
func NewBlockingLimiter( delegate core.Limiter, ) *BlockingLimiter
NewBlockingLimiter will create a new blocking limiter
func (*BlockingLimiter) Acquire ¶
Acquire a token from the limiter. Returns an Optional.empty() if the limit has been exceeded. If acquired the caller must call one of the Listener methods when the operation has been completed to release the count.
context Context for the request. The context is used by advanced strategies such as LookupPartitionStrategy.
func (BlockingLimiter) String ¶
func (l BlockingLimiter) String() string
type BlockingListener ¶
type BlockingListener struct {
// contains filtered or unexported fields
}
BlockingListener wraps the wrapped Limiter's Listener to correctly handle releasing blocked connections
func (*BlockingListener) OnDropped ¶
func (l *BlockingListener) OnDropped()
OnDropped is called to indicate the request failed and was dropped due to being rejected by an external limit or hitting a timeout. Loss based Limit implementations will likely do an aggressive reducing in limit when this happens.
func (*BlockingListener) OnIgnore ¶
func (l *BlockingListener) OnIgnore()
OnIgnore is called to indicate the operation failed before any meaningful RTT measurement could be made and should be ignored to not introduce an artificially low RTT.
func (*BlockingListener) OnSuccess ¶
func (l *BlockingListener) OnSuccess()
OnSuccess is called as a notification that the operation succeeded and internally measured latency should be used as an RTT sample.
type DefaultLimiter ¶
type DefaultLimiter struct {
// contains filtered or unexported fields
}
DefaultLimiter is a Limiter that combines a plugable limit algorithm and enforcement strategy to enforce concurrency limits to a fixed resource.
func NewDefaultLimiter ¶
func NewDefaultLimiter( limit core.Limit, minWindowTime int64, maxWindowTime int64, minRTTThreshold int64, windowSize int, strategy core.Strategy, logger limit.Logger, registry core.MetricRegistry, ) (*DefaultLimiter, error)
NewDefaultLimiter creates a new DefaultLimiter.
func NewDefaultLimiterWithDefaults ¶
func NewDefaultLimiterWithDefaults( name string, strategy core.Strategy, logger limit.Logger, registry core.MetricRegistry, tags ...string, ) (*DefaultLimiter, error)
NewDefaultLimiterWithDefaults will create a DefaultLimit Limiter with the provided minimum config.
func (*DefaultLimiter) Acquire ¶
Acquire a token from the limiter. Returns an Optional.empty() if the limit has been exceeded. If acquired the caller must call one of the Listener methods when the operation has been completed to release the count.
context Context for the request. The context is used by advanced strategies such as LookupPartitionStrategy.
func (*DefaultLimiter) EstimatedLimit ¶
func (l *DefaultLimiter) EstimatedLimit() int
EstimatedLimit will return the current estimated limit.
func (*DefaultLimiter) String ¶
func (l *DefaultLimiter) String() string
type DefaultListener ¶
type DefaultListener struct {
// contains filtered or unexported fields
}
DefaultListener for
func (*DefaultListener) OnDropped ¶
func (l *DefaultListener) OnDropped()
OnDropped is called to indicate the request failed and was dropped due to being rejected by an external limit or hitting a timeout. Loss based Limit implementations will likely do an aggressive reducing in limit when this happens.
func (*DefaultListener) OnIgnore ¶
func (l *DefaultListener) OnIgnore()
OnIgnore is called to indicate the operation failed before any meaningful RTT measurement could be made and should be ignored to not introduce an artificially low RTT.
func (*DefaultListener) OnSuccess ¶
func (l *DefaultListener) OnSuccess()
OnSuccess is called as a notification that the operation succeeded and internally measured latency should be used as an RTT sample.
type LifoBlockingLimiter ¶
type LifoBlockingLimiter struct {
// contains filtered or unexported fields
}
LifoBlockingLimiter implements a Limiter that blocks the caller when the limit has been reached. This strategy ensures the resource is properly protected but favors availability over latency by not fast failing requests when the limit has been reached. To help keep success latencies low and minimize timeouts any blocked requests are processed in last in/first out order.
Use this limiter only when the concurrency model allows the limiter to be blocked.
func NewLifoBlockingLimiter ¶
func NewLifoBlockingLimiter( delegate core.Limiter, maxBacklogSize int, maxBacklogTimeout time.Duration, ) *LifoBlockingLimiter
NewLifoBlockingLimiter will create a new LifoBlockingLimiter
func NewLifoBlockingLimiterWithDefaults ¶
func NewLifoBlockingLimiterWithDefaults( delegate core.Limiter, ) *LifoBlockingLimiter
NewLifoBlockingLimiterWithDefaults will create a new LifoBlockingLimiter with default values.
func (*LifoBlockingLimiter) Acquire ¶
Acquire a token from the limiter. Returns an Optional.empty() if the limit has been exceeded. If acquired the caller must call one of the Listener methods when the operation has been completed to release the count.
context Context for the request. The context is used by advanced strategies such as LookupPartitionStrategy.
func (*LifoBlockingLimiter) String ¶
func (l *LifoBlockingLimiter) String() string
type LifoBlockingListener ¶
type LifoBlockingListener struct {
// contains filtered or unexported fields
}
LifoBlockingListener implements a blocking listener for the LifoBlockingListener
func (*LifoBlockingListener) OnDropped ¶
func (l *LifoBlockingListener) OnDropped()
OnDropped is called to indicate the request failed and was dropped due to being rejected by an external limit or hitting a timeout. Loss based Limit implementations will likely do an aggressive reducing in limit when this happens.
func (*LifoBlockingListener) OnIgnore ¶
func (l *LifoBlockingListener) OnIgnore()
OnIgnore is called to indicate the operation failed before any meaningful RTT measurement could be made and should be ignored to not introduce an artificially low RTT.
func (*LifoBlockingListener) OnSuccess ¶
func (l *LifoBlockingListener) OnSuccess()
OnSuccess is called as a notification that the operation succeeded and internally measured latency should be used as an RTT sample.