none.go

 1package ratelimit
 2
 3import "context"
 4
 5// None implements a no-op rate limiter which effectively disables client-side
 6// rate limiting (also known as "retry quotas").
 7//
 8// GetToken does nothing and always returns a nil error. The returned
 9// token-release function does nothing, and always returns a nil error.
10//
11// AddTokens does nothing and always returns a nil error.
12var None = &none{}
13
14type none struct{}
15
16func (*none) GetToken(ctx context.Context, cost uint) (func() error, error) {
17	return func() error { return nil }, nil
18}
19
20func (*none) AddTokens(v uint) error { return nil }