limit

package
v0.0.0-...-96c8be2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotApplicable = notApplicable{}
View Source
var Unknown = unknown{}

Functions

This section is empty.

Types

type Amount

type Amount interface {
	Increment(Amount) Amount
	Decrement(Amount) Amount
	Equals(Amount) bool
	Exceeds(Amount) bool
	Zero() Amount
	Measure() Measure
	// contains filtered or unexported methods
}

type Count

type Count amount

func (Count) Decrement

func (c Count) Decrement(amount Amount) Amount

func (Count) Equals

func (c Count) Equals(amount Amount) bool

func (Count) Exceeds

func (c Count) Exceeds(amount Amount) bool

func (Count) Increment

func (c Count) Increment(amount Amount) Amount

func (Count) Measure

func (c Count) Measure() Measure

func (Count) Zero

func (c Count) Zero() Amount

type DataSize

type DataSize amount

func (DataSize) Decrement

func (d DataSize) Decrement(amount Amount) Amount

func (DataSize) Equals

func (d DataSize) Equals(amount Amount) bool

func (DataSize) Exceeds

func (d DataSize) Exceeds(amount Amount) bool

func (DataSize) Increment

func (d DataSize) Increment(amount Amount) Amount

func (DataSize) Measure

func (d DataSize) Measure() Measure

func (DataSize) Zero

func (d DataSize) Zero() Amount

type Dirtyable

type Dirtyable interface {
	IsDirty() bool
	ClearDirty()
}

type ExceededError

type ExceededError struct {
	gomerr.Gomerr
	Limiter   interface{}
	Limited   interface{}
	Limit     Amount
	Current   Amount
	Attempted Amount
}

func Exceeded

func Exceeded(limiter, limited interface{}, limit, current, attempted Amount) *ExceededError

func UnquantifiedExcess

func UnquantifiedExcess(limiter, limited interface{}) *ExceededError

type Limited

type Limited interface {
	Limiter() (Limiter, gomerr.Gomerr)
	DefaultLimit() Amount
	LimitAmount() Amount
}

type Limiter

type Limiter interface {
	Dirtyable
	Current(limited Limited) Amount
	SetCurrent(limited Limited, current Amount)
	Override(limited Limited) Amount
	SetOverride(limited Limited, override Amount)
	Maximum(limited Limited) Amount
}

type Measure

type Measure string

type TrackingLimiter

type TrackingLimiter struct {
	Currents  map[string]amount
	Overrides map[string]amount
	// contains filtered or unexported fields
}

func (*TrackingLimiter) ClearDirty

func (l *TrackingLimiter) ClearDirty()

func (*TrackingLimiter) Current

func (l *TrackingLimiter) Current(limited Limited) Amount

func (*TrackingLimiter) IsDirty

func (l *TrackingLimiter) IsDirty() bool

func (*TrackingLimiter) Maximum

func (l *TrackingLimiter) Maximum(limited Limited) Amount

func (*TrackingLimiter) Override

func (l *TrackingLimiter) Override(limited Limited) Amount

func (*TrackingLimiter) SetCurrent

func (l *TrackingLimiter) SetCurrent(limited Limited, current Amount)

func (*TrackingLimiter) SetOverride

func (l *TrackingLimiter) SetOverride(limited Limited, override Amount)

Jump to

Keyboard shortcuts

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