Documentation
¶
Index ¶
- Constants
- Variables
- type Bitrate
- type DestinationsUsage
- func (d *DestinationsUsage) Allocate(debugletID uuid.UUID, executorID string, destinations []string, ...) error
- func (d *DestinationsUsage) Cap(destination string) Bitrate
- func (d *DestinationsUsage) CheckCapacity(destination string, minimum Bitrate) error
- func (d *DestinationsUsage) Fairshare(destination string) iter.Seq2[string, Bitrate]
- func (d *DestinationsUsage) Insert(debugletID uuid.UUID, destination, executorID string, minimum, maximum Bitrate) error
- func (d *DestinationsUsage) Len() int
- func (d *DestinationsUsage) Remove(debugletID uuid.UUID, destination string)
- func (d *DestinationsUsage) SetLimit(destination string, limit Bitrate) error
Constants ¶
const ( Bit Bitrate = 1 Kilobit = 1000 * Bit Megabit = 1000 * Kilobit Gigabit = 1000 * Megabit Terabit = 1000 * Gigabit Petabit = 1000 * Terabit Byte = 8 * Bit Kilobyte = 1000 * Byte Megabyte = 1000 * Kilobyte Gigabyte = 1000 * Megabyte Terabyte = 1000 * Gigabyte Petabyte = 1000 * Terabyte )
const MaxBitrate = Petabit
MaxBitrate is the largest bandwidth the dispatcher admits on any boundary. It is far above any capacity a real executor announces and low enough that the aggregate of every run a schedule can hold stays an exact int64. api/openapi.yaml documents the same bound for floor_bw and ceil_bw.
const MaxByteCount = math.MaxInt64 / bitsPerByte
MaxByteCount is the largest byte count that has an exact bit count.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Bitrate ¶
type Bitrate int64
Bitrate in bits/s.
Can also be used to generally indicate size.
func AddBitrate ¶
AddBitrate adds two bandwidths and reports whether the sum is exact. Every aggregate admission decision uses it, so a sum that would wrap rejects the request instead of admitting it against a negative total.
func FromBytes ¶
FromBytes converts a byte count into bits. A count beyond MaxByteCount in either direction has no exact bit count and saturates, rather than wrapping into a bitrate of the opposite sign.
func (Bitrate) Bytes ¶
Bytes is the buffer size that holds b bits, rounded up to a whole byte. It is a size, so it is defined for a non-negative bitrate: a negative one is a debt, has no buffer size and reports zero. Use Bitrate.SignedBytes to convert a signed token balance.
func (Bitrate) SignedBytes ¶
SignedBytes converts a signed bit count into whole bytes, rounding towards negative infinity. Applied to a token balance it reports only bytes that are fully covered and never erases part of a debt: -8 bits is one byte owed and -1 bit is still one byte owed, where rounding towards zero reports none of either and grants the next reservation early. It is exact for every int64.
type DestinationsUsage ¶
type DestinationsUsage struct {
// contains filtered or unexported fields
}
func NewDestinations ¶
func NewDestinations(defaultCap Bitrate) *DestinationsUsage
func (*DestinationsUsage) Allocate ¶
func (d *DestinationsUsage) Allocate(debugletID uuid.UUID, executorID string, destinations []string, minimum, maximum 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) Cap ¶
func (d *DestinationsUsage) Cap(destination string) Bitrate
func (*DestinationsUsage) CheckCapacity ¶
func (d *DestinationsUsage) CheckCapacity(destination string, minimum 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) 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.
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) Insert ¶
func (d *DestinationsUsage) Insert(debugletID uuid.UUID, destination, executorID string, minimum, maximum 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) SetLimit ¶
func (d *DestinationsUsage) SetLimit(destination string, limit 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.