allocator

package
v0.0.0-...-d32dafa Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocateIP

func AllocateIP(ctx context.Context, cli *clientv3.Client, ipHeap *IPHeap, publicKey string) (net.IP, error)

func LoadAvailableIPs

func LoadAvailableIPs(ctx context.Context, cli *clientv3.Client) ([]net.IP, error)

func ReleaseIP

func ReleaseIP(ctx context.Context, cli *clientv3.Client, ip net.IP) error

func RemoveIPFromHeap

func RemoveIPFromHeap(ipHeap *IPHeap, ip net.IP)

func WatchAvailableIPs

func WatchAvailableIPs(ctx context.Context, cli *clientv3.Client, ipHeap *IPHeap)

Types

type IPAllocator

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

func NewIPAllocator

func NewIPAllocator(cidr string) (*IPAllocator, error)

func (*IPAllocator) Allocate

func (a *IPAllocator) Allocate() (string, error)

type IPHeap

type IPHeap []net.IP

IPHeap implements a min-heap for IP addresses (net.IP)

func (IPHeap) Len

func (h IPHeap) Len() int

func (IPHeap) Less

func (h IPHeap) Less(i, j int) bool

func (*IPHeap) Pop

func (h *IPHeap) Pop() interface{}

func (*IPHeap) Push

func (h *IPHeap) Push(x interface{})

func (IPHeap) Swap

func (h IPHeap) Swap(i, j int)

Jump to

Keyboard shortcuts

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