quota

package
v1.0.0-alpha.36 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRateExceeded        = api.Errorf(api.Code_RESOURCE_EXHAUSTED, "request rate limit exceeded")
	ErrThroughputExceeded  = api.Errorf(api.Code_RESOURCE_EXHAUSTED, "request throughput limit exceeded")
	ErrStorageSizeExceeded = api.Errorf(api.Code_RESOURCE_EXHAUSTED, "data size limit exceeded")
)

Functions

func Allow

func Allow(ctx context.Context, namespace string, reqSize int) error

Allow checks rate, write throughput and storage size limits for the namespace and returns error if at least one of them is exceeded

Types

type Manager

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

type State

type State struct {
	Rate               *rate.Limiter
	WriteThroughput    *rate.Limiter
	ReadThroughput     *rate.Limiter
	Size               atomic.Int64
	SizeUpdateAt       atomic.Int64
	TenantSizeUpdateAt atomic.Int64
	SizeLock           sync.Mutex
	TenantSizeLock     sync.Mutex
}

func GetState

func GetState(namespace string) *State

GetState returns quota state of the given namespace

Jump to

Keyboard shortcuts

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