func (g *GCRARateLimiter) SetMaxCASAttemptsLimit(limit int) {
	g.maxCASAttemptsLimit = limit
}
SetMaxCASAttemptsLimit allows you to set the maxCASAttempts limit. This is set to 10
be default.
package throttled
import (
	"fmt"
	"time"
)
const (
	maxCASAttempts = 10
)
type RateLimiter interface {
	RateLimit(key string, quantity int) (bool, RateLimitResult, error)
}
type RateLimitResult struct {
	Limit int
	Remaining int
	ResetAfter time.Duration
	RetryAfter time.Duration
}
type limitResult struct {
	limited bool
}
func (r *limitResult) Limited() bool { return r.limited }
type rateLimitResult struct {
	limitResult
	limit, remaining  int
	reset, retryAfter time.Duration
}
func (r *rateLimitResult) Limit() int                { return r.limit }
func (r *rateLimitResult) Remaining() int            { return r.remaining }
func (r *rateLimitResult) Reset() time.Duration      { return r.reset }
func (r *rateLimitResult) RetryAfter() time.Duration { return r.retryAfter }
type Rate struct {
	period time.Duration  
	count  int            
}
type RateQuota struct {
	MaxRate  Rate
	MaxBurst int
}
func PerSec(n int) Rate { return Rate{time.Second / time.Duration(n), n} }
func PerMin(n int) Rate { return Rate{time.Minute / time.Duration(n), n} }
func PerHour(n int) Rate { return Rate{time.Hour / time.Duration(n), n} }
func PerDay(n int) Rate { return Rate{24 * time.Hour / time.Duration(n), n} }
func PerDuration(n int, d time.Duration) Rate { return Rate{d / time.Duration(n), n} }
type GCRARateLimiter struct {
	limit int
	delayVariationTolerance time.Duration
	emissionInterval time.Duration
	store GCRAStore
	maxCASAttemptsLimit int
}
func NewGCRARateLimiter(st GCRAStore, quota RateQuota) (*GCRARateLimiter, error) {
	if quota.MaxBurst < 0 {
		return nil, fmt.Errorf("invalid RateQuota %#v; MaxBurst must be greater than zero", quota)
	}
	if quota.MaxRate.period <= 0 {
		return nil, fmt.Errorf("invalid RateQuota %#v; MaxRate must be greater than zero", quota)
	}
	return &GCRARateLimiter{
		delayVariationTolerance: quota.MaxRate.period * (time.Duration(quota.MaxBurst) + 1),
		emissionInterval:        quota.MaxRate.period,
		limit:                   quota.MaxBurst + 1,
		store:                   st,
		maxCASAttemptsLimit:     maxCASAttempts,
	}, nil
}