txlimiter

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Impl

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

Impl limits the total number of transactions a single user may use concurrently. Implements TxLimiter.

func (*Impl) Get

func (txl *Impl) Get(immediate *querypb.VTGateCallerID, effective *vtrpcpb.CallerID) bool

Get tells whether given user (identified by context.Context) is allowed to use another transaction slot. If this method returns true, it's necessary to call Release once transaction is returned to the pool. Implements TxLimiter.Get

func (*Impl) Release

func (txl *Impl) Release(immediate *querypb.VTGateCallerID, effective *vtrpcpb.CallerID)

Release marks that given user (identified by caller ID) is no longer using a transaction slot. Implements TxLimiter.Release

type TxAllowAll

type TxAllowAll struct{}

TxAllowAll is a TxLimiter that allows all Get requests and does no tracking. Implements Txlimiter.

func (*TxAllowAll) Get

func (txa *TxAllowAll) Get(immediate *querypb.VTGateCallerID, effective *vtrpcpb.CallerID) bool

Get always returns true (allows all requests). Implements TxLimiter.Get

func (*TxAllowAll) Release

func (txa *TxAllowAll) Release(immediate *querypb.VTGateCallerID, effective *vtrpcpb.CallerID)

Release is noop, because TxAllowAll does no tracking. Implements TxLimiter.Release

type TxLimiter

type TxLimiter interface {
	Get(immediate *querypb.VTGateCallerID, effective *vtrpcpb.CallerID) bool
	Release(immediate *querypb.VTGateCallerID, effective *vtrpcpb.CallerID)
}

TxLimiter is the transaction limiter interface.

func New

func New(slotCount int, maxPerUser float64, enabled, dryRun, byUsername, byPrincipal, byComponent, bySubcomponent bool) TxLimiter

New creates a new TxLimiter. slotCount: total slot count in transaction pool maxPerUser: fraction of the pool that may be taken by single user enabled: should the feature be enabled. If false, will return "allow-all" limiter dryRun: if true, does no limiting, but records stats of the decisions made byXXX: whether given field from immediate/effective caller id should be taken into account when deciding "user" identity for purposes of transaction limiting.

Jump to

Keyboard shortcuts

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