numberallocator

package
v0.0.0-...-6f909bf Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFull      = errors.New("range is full")
	ErrAllocated = errors.New("provided IP is already allocated")
)

Functions

This section is empty.

Types

type Range

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

func NewAllocatorRange

func NewAllocatorRange(base, max int, allocatorFactory allocator.AllocatorFactory) (*Range, error)

func NewRange

func NewRange(base, max int) (*Range, error)

func (*Range) Allocate

func (r *Range) Allocate(vni int) error

func (*Range) AllocateNext

func (r *Range) AllocateNext() (int, error)

AllocateNext returns the next available vni in the range

func (*Range) Desc

func (r *Range) Desc() string

func (*Range) ForEach

func (r *Range) ForEach(fn func(vni int) error)

ForEach calls the provided function for each allocated VNI in the range

func (*Range) Free

func (r *Range) Free() int

Free returns the count of freed vni

func (*Range) Has

func (r *Range) Has(vni int) bool

Has returns true if the provided VNI is already allocated and a call

func (*Range) Release

func (r *Range) Release(vni int)

Release the VNI to the VNI pool

func (*Range) Used

func (r *Range) Used() int

Used return the count of VNI used in the range

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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