Documentation
¶
Overview ¶
Package token contains a standard token bucket implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket is an implementation of a standard token Bucket. The Bucket is refilled at some interval to a maximum value.
func New ¶
New creates a Bucket instance. size is how many tokens we can hold. incr is the amount of tokens to add at a time. interval is how often to add tokens.
func (*Bucket) Close ¶
func (b *Bucket) Close()
close stops the token Bucket's goroutine. This should be called before throwing away the Bucket. If you use the token Bucket after this is called, this can cause major problems like causing the token() call to block forever, as there are no more tokens being added.
Click to show internal directories.
Click to hide internal directories.