Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrLimitReached = errors.New("limit reached")
ErrLimitReached is the error returned by the Limiter and LimitWriter when the predefined limit has been reached
Functions ¶
func FileExists ¶
func RandomString ¶
RandomString returns a random string with a given length
Types ¶
type Limiter ¶ added in v1.1.3
type Limiter struct {
// contains filtered or unexported fields
}
Limiter is a helper that allows adding values up to a well-defined limit. Once the limit is reached ErrLimitReached will be returned. Limiter may be used by multiple goroutines.
func NewLimiter ¶ added in v1.1.3
NewLimiter creates a new Limiter
func (*Limiter) Add ¶ added in v1.1.3
Add adds n to the limiters internal value, but only if the limit has not been reached. If the limit would be exceeded after adding n, ErrLimitReached is returned.
func (*Limiter) Set ¶ added in v1.1.3
Set sets the value of the limiter to n. This function ignores the limit. It is meant to set the value based on reality.
Click to show internal directories.
Click to hide internal directories.