portallocator

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupRuntimePortAllocator

func SetupRuntimePortAllocator(client client.Client, pr *net.PortRange, getReservedPorts func(client client.Client) (ports []int, err error))

SetupRuntimePortAllocator instantiates the global singleton rpa, use BitMap port allocating policy

func SetupRuntimePortAllocatorWithType added in v0.8.0

func SetupRuntimePortAllocatorWithType(client client.Client, pr *net.PortRange, allocatePolicy AllocatePolicy, getReservedPorts func(client client.Client) (ports []int, err error))

SetupRuntimePortAllocatorWithType instantiates the global singleton rpa with specified port allocating policy

Types

type AllocatePolicy added in v0.8.0

type AllocatePolicy string
const (
	Random AllocatePolicy = "random"
	BitMap AllocatePolicy = "bitmap"
)

type BatchAllocatorInterface added in v0.8.0

type BatchAllocatorInterface interface {
	Allocate(int) error

	Release(int) error

	AllocateBatch(portNum int) ([]int, error)
	// contains filtered or unexported methods
}

type BitMapAllocator added in v0.8.0

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

func (*BitMapAllocator) Allocate added in v0.8.0

func (b *BitMapAllocator) Allocate(port int) error

func (*BitMapAllocator) AllocateBatch added in v0.8.0

func (b *BitMapAllocator) AllocateBatch(portNum int) (ports []int, err error)

func (*BitMapAllocator) Release added in v0.8.0

func (b *BitMapAllocator) Release(port int) error

type RandomAllocator added in v0.8.0

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

func (*RandomAllocator) Allocate added in v0.8.0

func (r *RandomAllocator) Allocate(port int) error

func (*RandomAllocator) AllocateBatch added in v0.8.0

func (r *RandomAllocator) AllocateBatch(portNum int) (ports []int, err error)

func (*RandomAllocator) Release added in v0.8.0

func (r *RandomAllocator) Release(i int) error

type RuntimePortAllocator

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

RuntimePortAllocator is an allocator resonsible for maintaining port usage information given a user-defined port range. It allocates and releases ports when a port is requested or reclaimed by a runtime.

func GetRuntimePortAllocator

func GetRuntimePortAllocator() (*RuntimePortAllocator, error)

GetRuntimePortAllocator restore the port allocator and gets the global singleton. This should be the only way others access the RuntimePortAllocator and it must be called after SetupRuntimePortAllocator

func (*RuntimePortAllocator) GetAvailablePorts

func (alloc *RuntimePortAllocator) GetAvailablePorts(portNum int) (ports []int, err error)

GetAvailablePorts requests portNum ports from the port allocator. It returns an int array with allocated ports in it.

func (*RuntimePortAllocator) ReleaseReservedPorts

func (alloc *RuntimePortAllocator) ReleaseReservedPorts(ports []int)

ReleaseReservedPorts releases all the ports in the given int array.

Jump to

Keyboard shortcuts

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