collection

package
v1.2.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package collection contains the limiting-host ratelimit usage tracking and enforcing logic, which acts as a quotas.Collection.

At a very high level, this wraps a quotas.Limiter to do a few additional things in the context of the github.com/uber/cadence/common/quotas/global ratelimiter system:

  • keep track of usage per key (quotas.Limiter does not support this natively, nor should it)
  • periodically report usage to each key's "aggregator" host (batched and fanned out in parallel)
  • apply the aggregator's returned per-key RPS limits to future requests
  • fall back to the wrapped limiter in case of failures (handled internally in internal.FallbackLimiter)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection struct {
	// contains filtered or unexported fields
}

func New

func New(
	fallback quotas.LimiterFactory,
	updateInterval dynamicconfig.DurationPropertyFn,
	logger log.Logger,
	met metrics.Client,
) *Collection

func (*Collection) For

func (c *Collection) For(key string) Limiter

func (*Collection) OnStart

func (c *Collection) OnStart(ctx context.Context) error

OnStart follows fx's OnStart hook semantics.

func (*Collection) OnStop

func (c *Collection) OnStop(ctx context.Context) error

OnStop follows fx's OnStop hook semantics.

func (*Collection) TestOverrides

func (c *Collection) TestOverrides(t *testing.T, timesource clock.TimeSource)

type Limiter

type Limiter interface {
	Allow() bool
}

Limiter is a simplified quotas.Limiter API, covering the only global-ratelimiter-used API: Allow.

This is largely because Reserve() and Wait() are difficult to monitor for usage-tracking purposes. If converted to the wrapper, Reserve can probably be added pretty easily.

Directories

Path Synopsis
Package internal protects these types' concurrency primitives and other internals from accidental misuse.
Package internal protects these types' concurrency primitives and other internals from accidental misuse.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL