subnet

package
v0.0.0-...-f30a8d1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSubnetNotFound = errors.New("subnet not found")

ErrSubnetNotFound is used to inform the subnet is not being managed

Functions

func NewAllocator

func NewAllocator() *allocator

Initializes a new subnet IP allocator

Types

type Allocator

type Allocator interface {
	AddOrUpdateSubnet(name string, subnets []*net.IPNet, excludeSubnets ...*net.IPNet) error
	DeleteSubnet(name string)
	GetSubnets(name string) ([]*net.IPNet, error)
	AllocateUntilFull(name string) error
	AllocateIPPerSubnet(name string, ips []*net.IPNet) error
	AllocateNextIPs(name string) ([]*net.IPNet, error)
	ReleaseIPs(name string, ips []*net.IPNet) error
	ConditionalIPRelease(name string, ips []*net.IPNet, predicate func() (bool, error)) (bool, error)
	ForSubnet(name string) NamedAllocator
	GetSubnetName(subnets []*net.IPNet) (string, bool)
}

Allocator manages the allocation of IP within specific set of subnets identified by a name. Allocator should be threadsafe.

type IPAllocator

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

func (*IPAllocator) AllocateIPs

func (ipAllocator *IPAllocator) AllocateIPs(ips []*net.IPNet) error

AllocateIPs allocates the requested IPs

func (*IPAllocator) AllocateNextIPs

func (ipAllocator *IPAllocator) AllocateNextIPs() ([]*net.IPNet, error)

AllocateNextIPs allocates the next available IPs

func (*IPAllocator) ReleaseIPs

func (ipAllocator *IPAllocator) ReleaseIPs(ips []*net.IPNet) error

ReleaseIPs release the provided IPs

type NamedAllocator

type NamedAllocator interface {
	AllocateIPs(ips []*net.IPNet) error
	AllocateNextIPs() ([]*net.IPNet, error)
	ReleaseIPs(ips []*net.IPNet) error
}

NamedAllocator manages the allocation of IPs within a specific subnet

Jump to

Keyboard shortcuts

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