Documentation
¶
Overview ¶
Package limit supports enforcing the maximum number of simultaneous time-limited resources by user
Index ¶
- func Confirm(confirm chan<- struct{}) func()
- type Limit
- func (l *Limit) FlushAll()
- func (l *Limit) GetSessions(user string) int
- func (l *Limit) ProvisionalRequest(who string, exp int64) (func(), error)
- func (l *Limit) Request(who string, exp int64) bool
- func (l *Limit) WithFlush(ctx context.Context, interval time.Duration) *Limit
- func (l *Limit) WithMax(max int) *Limit
- func (l *Limit) WithNow(now func() int64) *Limit
- func (l *Limit) WithProvisionalPeriod(interval time.Duration) *Limit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Limit ¶
Limit represents a limit store
func New ¶
func New() *Limit
New creates a new Limit with optional hourly flushing to avoid memory leakage
func (*Limit) GetSessions ¶
GetSessions returns the current sessions for a user
func (*Limit) ProvisionalRequest ¶
ProvisionalRequest checks if a user has spare capacity within their limit adding their request provisionally (with a delayed autodelete) if approved. The autodelete can be cancelled with the returned CancelFunc, in order to make the booking. If there is no quota left, an error is returned
func (*Limit) Request ¶
Request makes a provisional request, and immediately confirms it. Used for testing.
Click to show internal directories.
Click to hide internal directories.