{"modulePath":"github.com/UnityTech/client-go","version":"v11.0.0+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package flowcontrol\n\n## Types\n\n```go\ntype Backoff struct {\n\tsync.Mutex\n\tClock clock.Clock\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewBackOff(initial, max time.Duration) *Backoff\n```\n\n```go\nfunc NewFakeBackOff(initial, max time.Duration, tc *clock.FakeClock) *Backoff\n```\n\n```go\nfunc (p *Backoff) DeleteEntry(id string)\n```\n\n```go\nfunc (p *Backoff) GC()\n```\nGarbage collect records that have aged past maxDuration. Backoff users are expected to invoke this periodically.\n\n```go\nfunc (p *Backoff) Get(id string) time.Duration\n```\nGet the current backoff Duration\n\n```go\nfunc (p *Backoff) IsInBackOffSince(id string, eventTime time.Time) bool\n```\nReturns True if the elapsed time since eventTime is smaller than the current backoff window\n\n```go\nfunc (p *Backoff) IsInBackOffSinceUpdate(id string, eventTime time.Time) bool\n```\nReturns True if time since lastupdate is less than the current backoff window.\n\n```go\nfunc (p *Backoff) Next(id string, eventTime time.Time)\n```\nmove backoff to the next mark, capping at maxDuration\n\n```go\nfunc (p *Backoff) Reset(id string)\n```\nReset forces clearing of all backoff data for a given key.\n\n```go\ntype Clock interface {\n\tNow() time.Time\n\tSleep(time.Duration)\n}\n```\nAn injectable, mockable clock interface.\n\n```go\ntype RateLimiter interface {\n\t// TryAccept returns true if a token is taken immediately. Otherwise,\n\t// it returns false.\n\tTryAccept() bool\n\t// Accept returns once a token becomes available.\n\tAccept()\n\t// Stop stops the rate limiter, subsequent calls to CanAccept will return false\n\tStop()\n\t// QPS returns QPS of this rate limiter\n\tQPS() float32\n}\n```\n\n```go\nfunc NewFakeAlwaysRateLimiter() RateLimiter\n```\n\n```go\nfunc NewFakeNeverRateLimiter() RateLimiter\n```\n\n```go\nfunc NewTokenBucketRateLimiter(qps float32, burst int) RateLimiter\n```\nNewTokenBucketRateLimiter creates a rate limiter which implements a token bucket approach. The rate limiter allows bursts of up to 'burst' to exceed the QPS, while still maintaining a smoothed qps rate of 'qps'. The bucket is initially filled with 'burst' tokens, and refills at a rate of 'qps'. The maximum number of tokens in the bucket is capped at 'burst'.\n\n```go\nfunc NewTokenBucketRateLimiterWithClock(qps float32, burst int, c Clock) RateLimiter\n```\nNewTokenBucketRateLimiterWithClock is identical to NewTokenBucketRateLimiter but allows an injectable clock, for testing.\n\n","path":"github.com/UnityTech/client-go/util/flowcontrol","name":"flowcontrol","synopsis":"","isRedistributable":true}
