rate

package
v0.0.0-...-f70214e Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCastingIntoSWLimiter = errors.New("error type casting sliding window limiter")

Functions

func AuthorKey

func AuthorKey(id id.PR) string

func OrgKey

func OrgKey(id id.PR) string

func RepoKey

func RepoKey(id id.PR) string

Types

type Getter

type Getter interface {
	Name() string
	GetOrCreate(ctx context.Context, key string, limit Limit) (Limiter, error)
	Close()
}

func NewSWRegistry

func NewSWRegistry(name string, client *dynamodb.Client, props lim.DynamoDBTableProperties,
	clock clockwork.Clock) Getter

type Keyer

type Keyer func(id id.PR) string

type Limit

type Limit struct {
	Window    time.Duration `dynamodbav:"-"`
	Value     int64         `dynamodbav:"value"`
	WindowStr string        `dynamodbav:"window"`
}

type Limiter

type Limiter interface {
	Limit(ctx context.Context) (time.Duration, error)
}

type LimiterConfig

type LimiterConfig struct {
	Default   Limit            `dynamodbav:"default"`
	Overrides map[string]Limit `dynamodbav:"overrides"`
}

func (*LimiterConfig) Get

func (cfg *LimiterConfig) Get(key string) Limit

func (*LimiterConfig) Update

func (cfg *LimiterConfig) Update() error

Update is called everytime the store updates the config

type Mock

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

func (*Mock) Key

func (m *Mock) Key(_ id.PR) string

Key implements Throttler

func (*Mock) Name

func (m *Mock) Name() string

Name implements Throttler

func (*Mock) ShouldThrottle

func (m *Mock) ShouldThrottle(_ context.Context, _ id.PR) error

ShouldThrottle implements Throttler

type Throttler

type Throttler interface {
	ShouldThrottle(ctx context.Context, ID id.PR) error
	Name() string
	Key(id id.PR) string
}

func NewFacade

func NewFacade(metrics metrics.Emitter, throttlers ...Throttler) Throttler

func NewMockThrottler

func NewMockThrottler(err error) Throttler

func NewSlidingWindowLimiter

func NewSlidingWindowLimiter(keyer Keyer, registry Getter,
	store configstore.Getter[*LimiterConfig]) Throttler

Jump to

Keyboard shortcuts

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