set

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package set provides a thread-safe set of unsigned integers. It is used by the network modules to track allocated ports and prevent conflicts when multiple workloads request port reservations concurrently.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrConflict

type ErrConflict struct {
	Port uint
}

ErrConflict is returned when trying to add a value that is already present in the set.

func (ErrConflict) Error

func (e ErrConflict) Error() string

type UIntSet

type UIntSet struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

UIntSet is a set containing uint

func NewInt

func NewInt() *UIntSet

NewInt creates a new set for int

func (*UIntSet) Add

func (p *UIntSet) Add(i uint) error

Add tries to add port to the set. If port is already present errPortConflict is return otherwise nil is returned

func (*UIntSet) List

func (p *UIntSet) List() ([]uint, error)

List returns a list of uint present in the set

func (*UIntSet) Remove

func (p *UIntSet) Remove(i uint)

Remove removes a port from the set removes never fails cause if the port is not in the set remove is a nop-op

Jump to

Keyboard shortcuts

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