Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

17 lignes
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