app

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotRegistered = errors.New("debuglet has not been registered")
	ErrNotInPolicy   = errors.New("address has not been registered/not in policy")
)

Functions

This section is empty.

Types

type Limit

type Limit struct {
	Executor bitrate.Bitrate
	Address  bitrate.Bitrate
	Updated  bool
}

type Limiter

type Limiter struct {
	// contains filtered or unexported fields
}

Limiter keeps track of the bandwidth being used by individual debuglets as well as the maximum bandwidth any debuglet is allowed to use on a executor level as well as per destination.

func NewLimiter

func NewLimiter(l *zap.Logger) *Limiter

func (*Limiter) ExecutorCapacity

func (l *Limiter) ExecutorCapacity() bitrate.Bitrate

func (*Limiter) GetAddrLimit

func (l *Limiter) GetAddrLimit(ID uuid.UUID, addr string) (bitrate.Bitrate, bool, error)

func (*Limiter) GetExecLimit

func (l *Limiter) GetExecLimit(ID uuid.UUID) (bitrate.Bitrate, bool, error)

func (*Limiter) GetLimit

func (l *Limiter) GetLimit(ID uuid.UUID, addr string) (Limit, error)

func (*Limiter) InsertDebuglet

func (l *Limiter) InsertDebuglet(ID uuid.UUID, minimum, maximum bitrate.Bitrate, addrs []string) error

func (*Limiter) RemoveDebuglet

func (l *Limiter) RemoveDebuglet(ID uuid.UUID)

func (*Limiter) SetAddrCapacity

func (l *Limiter) SetAddrCapacity(addr string, c bitrate.Bitrate)

func (*Limiter) SetExecutorCapacity

func (l *Limiter) SetExecutorCapacity(c bitrate.Bitrate)

func (*Limiter) Wait

func (l *Limiter) Wait(ctx context.Context, direction TransferDirection, ID uuid.UUID, addr string, size bitrate.Bitrate) error

type TransferDirection

type TransferDirection = int
const (
	TransferIn TransferDirection = iota
	TransferOut
)

type UsageLimits

type UsageLimits struct {
	ExecutorRatelimit    bitrate.Bitrate
	ExecutorBurst        bitrate.Bitrate
	DestinationRatelimit bitrate.Bitrate
	DestinationBurst     bitrate.Bitrate
}

type UsageTracker

type UsageTracker struct {
	// contains filtered or unexported fields
}

UsageTracker tracks the amount of bandwidth that is being used by an individual debuglet. The idea is to set the executor and destination specific limit that is allowed by the debuglet and then UsageTracker.Wait will block the caller for the amount of time to ratelimit the bandwidth usage.

func NewUsageTracker

func NewUsageTracker(l *zap.Logger) *UsageTracker

func (*UsageTracker) Upsert

func (u *UsageTracker) Upsert(destination string, limits UsageLimits)

func (*UsageTracker) Wait

func (u *UsageTracker) Wait(ctx context.Context, dir TransferDirection, destination string, size bitrate.Bitrate) error

Wait uses a token bucket to sleep until either the context finishes or a packet of a given size has enough space

Jump to

Keyboard shortcuts

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