Documentation
¶
Overview ¶
Package usebudget models finite and unlimited approval use budgets.
Index ¶
- type Limit
- func (l Limit) Allows(used, reserved int) bool
- func (l Limit) Exhausted(used int) bool
- func (l Limit) IsFinite() bool
- func (l Limit) IsUnlimited() bool
- func (l Limit) MarshalJSON() ([]byte, error)
- func (l Limit) Remaining(used, reserved int) (int, bool)
- func (l *Limit) UnmarshalJSON(data []byte) error
- type Optional
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Limit ¶
type Limit int
Limit is either a positive finite use count or Unlimited.
const Unlimited Limit = 0
Unlimited represents a grant that remains usable until its time limit.
func (Limit) IsUnlimited ¶
IsUnlimited reports whether the limit has no use-count ceiling.
func (Limit) MarshalJSON ¶
MarshalJSON represents unlimited budgets as JSON null.
func (Limit) Remaining ¶
Remaining returns the finite remaining count and whether the limit is finite.
func (*Limit) UnmarshalJSON ¶
UnmarshalJSON accepts JSON null or a positive integer.
type Optional ¶
Optional preserves whether a request omitted its use limit, explicitly requested unlimited use, or requested a finite count.
func NoLimit ¶
func NoLimit() Optional
NoLimit returns an explicitly requested unlimited use budget.
func (Optional) MarshalJSON ¶
MarshalJSON delegates to the requested limit representation.
func (*Optional) UnmarshalJSON ¶
UnmarshalJSON marks the value as specified before decoding its limit.