Documentation
¶
Index ¶
- Variables
- type DestinationsUsage
- func (d *DestinationsUsage) Allocate(debugletID uuid.UUID, executorID string, destinations []string, ...) error
- func (d *DestinationsUsage) Allow(destination string)
- func (d *DestinationsUsage) Cap(destination string) bitrate.Bitrate
- func (d *DestinationsUsage) CheckCapacity(destination string, minimum bitrate.Bitrate) error
- func (d *DestinationsUsage) CheckLimit(destination string, limit bitrate.Bitrate) error
- func (d *DestinationsUsage) Denied(destination string) bool
- func (d *DestinationsUsage) Deny(destination string)
- func (d *DestinationsUsage) Fairshare(destination string) iter.Seq2[string, bitrate.Bitrate]
- func (d *DestinationsUsage) ForExecutor(executorID string) iter.Seq2[string, bitrate.Bitrate]
- func (d *DestinationsUsage) Insert(debugletID uuid.UUID, destination, executorID string, ...) error
- func (d *DestinationsUsage) Len() int
- func (d *DestinationsUsage) Remove(debugletID uuid.UUID, destination string)
- func (d *DestinationsUsage) ResetLimit(destination string)
- func (d *DestinationsUsage) SetLimit(destination string, limit bitrate.Bitrate) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrMinGreater = errors.New("minimum is greater than maximum bandwidth limit") ErrCapacityFull = errors.New("insufficient capacity") ErrPolicyConflict = errors.New("destination is already allocated to the run with different limits") ErrDenied = errors.New("destination is denied by its operator") )
Functions ¶
This section is empty.
Types ¶
type DestinationsUsage ¶
type DestinationsUsage struct {
// contains filtered or unexported fields
}
func NewDestinations ¶
func NewDestinations(defaultCap bitrate.Bitrate) *DestinationsUsage
func (*DestinationsUsage) Allocate ¶
func (d *DestinationsUsage) Allocate(debugletID uuid.UUID, executorID string, destinations []string, minimum, maximum bitrate.Bitrate) error
Allocate records the allocation of one debuglet on every given destination as a single decision. A repeated destination is charged once. A destination already recorded for the debuglet keeps its decision, so repeating an identical allocation charges nothing more, while a request that changes a recorded decision is rejected before anything is charged. If any destination cannot be charged, the destinations charged by this call are released again: the allocation either holds for every destination or for none.
func (*DestinationsUsage) Allow ¶ added in v0.3.0
func (d *DestinationsUsage) Allow(destination string)
Allow lifts a Deny. The limit of the destination is not changed.
func (*DestinationsUsage) CheckCapacity ¶
func (d *DestinationsUsage) CheckCapacity(destination string, minimum bitrate.Bitrate) error
CheckCapacity reports whether a floor still fits on a destination. The allocation path decides capacity itself, so this remains only as a capacity query for callers and tests of other packages.
func (*DestinationsUsage) CheckLimit ¶ added in v0.3.0
func (d *DestinationsUsage) CheckLimit(destination string, limit bitrate.Bitrate) error
CheckLimit reports whether SetLimit would accept limit, changing nothing.
func (*DestinationsUsage) Denied ¶ added in v0.3.0
func (d *DestinationsUsage) Denied(destination string) bool
Denied reports whether a destination is denied.
func (*DestinationsUsage) Deny ¶ added in v0.3.0
func (d *DestinationsUsage) Deny(destination string)
Deny refuses every new allocation on a destination, whatever its floor, zero included, until Allow. Allocations already recorded there stay until their runs end, and Fairshare gives them zero. The limit is kept as it is.
func (*DestinationsUsage) Fairshare ¶
Fairshares a destination address, then returns an iterator with tuples of (ID, new maximum bandwidth).
The fairshare respects the minimum bandwidth of each ID. It is guaranteed that ID.maximum >= fairshare >= ID.minimum for all IDs, except on a denied destination, where every ID is given zero.
An executor is a member of the tree of a destination exactly while it holds totals there, and it is a member once, so every node has its totals and each executor is yielded a single time.
func (*DestinationsUsage) ForExecutor ¶ added in v0.3.0
ForExecutor returns current destination shares for one executor. Like Fairshare, callers hold the destination store's lock while consuming it.
func (*DestinationsUsage) Insert ¶
func (d *DestinationsUsage) Insert(debugletID uuid.UUID, destination, executorID string, minimum, maximum bitrate.Bitrate) error
Insert records the allocation of one debuglet on a single destination. It is the one-destination form of Allocate and shares its behaviour.
func (*DestinationsUsage) Remove ¶
func (d *DestinationsUsage) Remove(debugletID uuid.UUID, destination string)
Remove releases the recorded allocation of one debuglet on one destination. The recorded decision, not the caller, determines what is subtracted, so a release always returns exactly the capacity its allocation charged. Removing an allocation that is not recorded does nothing.
func (*DestinationsUsage) ResetLimit ¶ added in v0.3.0
func (d *DestinationsUsage) ResetLimit(destination string)
ResetLimit removes the recorded limit of a destination, which then has the default capacity again. Unlike SetLimit it never refuses: floors already charged above the default stay, and nothing more is shared until they end.
func (*DestinationsUsage) SetLimit ¶
func (d *DestinationsUsage) SetLimit(destination string, limit bitrate.Bitrate) error
SetLimit records the total capacity of a destination. A limit below the floors already charged there is refused and nothing is recorded: those floors were admitted and stay, so the limit can be lowered once they end.