Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyLimit ¶
KeyLimit defines a concurrency limit for a set of keys.
All keys of one set share the same limit. Keys of different sets have separate limits.
Sets must not overlap.
type Limiter ¶
type Limiter interface { // Acquire attempts to reserve a slot without blocking. // // Returns a release function and true if successful. The function must be // called to release the limiter. The function must be called exactly once. // Calling the function more that once will cause incorrect behavior of the // limiter. // // Returns nil and false if fails. // // If the key was not defined in the limiter, no limit is applied. Acquire(key string) (ReleaseFunc, bool) }
type ReleaseFunc ¶
type ReleaseFunc func()
type SemaphoreLimiter ¶
type SemaphoreLimiter struct {
// contains filtered or unexported fields
}
func NewSemaphoreLimiter ¶
func NewSemaphoreLimiter(limits []KeyLimit) (*SemaphoreLimiter, error)
func (*SemaphoreLimiter) Acquire ¶
func (lr *SemaphoreLimiter) Acquire(key string) (ReleaseFunc, bool)
Click to show internal directories.
Click to hide internal directories.