Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MillisToTime ¶ added in v0.0.3
func TimeMillis ¶ added in v0.0.3
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
func NewTokenBucket ¶
NewTokenBucket returns a new rate limiter which uses the token bucket algorithm.
type RedigoStore ¶
type RedigoStore struct {
// contains filtered or unexported fields
}
func NewRedigoSWStore ¶ added in v0.0.4
func NewRedigoSWStore(pool *redis.Pool) RedigoStore
func NewRedigoStore ¶
func NewRedigoStore(pool *redis.Pool) RedigoStore
func (*RedigoStore) Inc ¶
func (s *RedigoStore) Inc(key string, rate, windowSize, now int) (StoreResponse, error)
type SlidingWindow ¶ added in v0.0.4
type SlidingWindow struct {
// contains filtered or unexported fields
}
func NewSlidingWindow ¶ added in v0.0.4
func NewSlidingWindow(identifier string, rate, windowSize int, store Store) SlidingWindow
NewSlidingWindow returns a new rate limiter which uses the token bucket algorithm.
func (*SlidingWindow) Allow ¶ added in v0.0.4
func (sw *SlidingWindow) Allow(key string) (bool, error)
func (*SlidingWindow) AllowWithStatus ¶ added in v0.0.4
func (sw *SlidingWindow) AllowWithStatus(key string) (Status, error)
Click to show internal directories.
Click to hide internal directories.