Documentation ¶
Index ¶
Constants ¶
const ( // DefaultPrefix is the default prefix to use for the key in the store. DefaultPrefix = "limiter" // DefaultMaxRetry is the default maximum number of key retries under // race condition (mainly used with database-based stores). DefaultMaxRetry = 3 // DefaultCleanUpInterval is the default time duration for cleanup. DefaultCleanUpInterval = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GJRMiddleware ¶
type GJRMiddleware struct {
Limiter *Limiter
}
GJRMiddleware is the go-json-rest middleware.
func NewGJRMiddleware ¶
func NewGJRMiddleware(limiter *Limiter) *GJRMiddleware
NewGJRMiddleware returns a new instance of go-json-rest middleware.
func (*GJRMiddleware) MiddlewareFunc ¶
func (m *GJRMiddleware) MiddlewareFunc(h rest.HandlerFunc) rest.HandlerFunc
MiddlewareFunc is the middleware method (handler).
type HTTPMiddleware ¶
type HTTPMiddleware struct {
Limiter *Limiter
}
HTTPMiddleware is the basic HTTP middleware.
func NewHTTPMiddleware ¶
func NewHTTPMiddleware(limiter *Limiter) *HTTPMiddleware
NewHTTPMiddleware return a new instance of go-json-rest middleware.
type Limiter ¶
Limiter is the limiter instance.
func NewLimiter ¶
NewLimiter returns an instance of Limiter.
type MemoryStore ¶
MemoryStore is the in-memory store.
type Rate ¶
Rate is the rate.
func NewRateFromFormatted ¶
NewRateFromFormatted returns the rate from the formatted version.
type RedisStore ¶
type RedisStore struct { // The prefix to use for the key. Prefix string // github.com/garyburd/redigo Pool instance. Pool *redis.Pool // The maximum number of retry under race conditions. MaxRetry int }
RedisStore is the redis store.
type RedisStoreFunc ¶
RedisStoreFunc is a redis store function.
type Store ¶
Store is the common interface for limiter stores.
func NewMemoryStore ¶
func NewMemoryStore() Store
NewMemoryStore creates a new instance of memory store with defaults.
func NewMemoryStoreWithOptions ¶
func NewMemoryStoreWithOptions(options StoreOptions) Store
NewMemoryStoreWithOptions creates a new instance of memory store with options.
func NewRedisStore ¶
NewRedisStore returns an instance of redis store.
func NewRedisStoreWithOptions ¶
func NewRedisStoreWithOptions(pool *redis.Pool, options StoreOptions) (Store, error)
NewRedisStoreWithOptions returns an instance of redis store with custom options.