Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

17 řádky
411 B

  1. package ratelimit
  2. import (
  3. "net/http"
  4. "time"
  5. )
  6. // TokenBucketStore is an interface for for any storage implementing
  7. // Token Bucket algorithm.
  8. type TokenBucketStore interface {
  9. InitRate(rate int, window time.Duration)
  10. Take(key string) (taken bool, remaining int, reset time.Time, err error)
  11. }
  12. // KeyFn is a function returning bucket key depending on request data.
  13. type KeyFn func(r *http.Request) string