Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

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