ratz/src/chatservers/timerate/ratewindow.go

type RateWindow

// New creates new rate limiter. A dataStore is internal limiter Data store, requestsLimit and windowSize are parameters of limiter e.g. requestsLimit: 5 and windowSize: 1*time.Minute means that limiter allows up to 5 requests per minute
func New(dataStore WindowStore, windowSize time.Duration) *RateWindow {}

// Inc increments limiter counter for a given key or returns error when it's not possible
func (r *RateWindow) Inc(key string) error {}

// All returns a counter of all keys in the current window
func (r *RateWindow) All(window string) (currentRate int, err error) {}

func (r *RateWindow) Purge(event string) {}

// Rate checks status of rate-limiting for a key. It returns error when limiter Data could not be read
func (r *RateWindow) Rate(key string) (currentRate int, err error) {}