Documentation ¶
Overview ¶
Provides port allocation and reservation.
Ports are a limited resource on a host and so must be shared via a central allocator. This package exposes Port - a valid IP port value - and methods for allocation and reservation of those ports.
Index ¶
Constants ¶
View Source
const InvalidPort = 0
Variables ¶
View Source
var ErrAllocationFailed = errors.New("A port could not be allocated.")
Functions ¶
This section is empty.
Types ¶
type Port ¶
type Port uint
An IP port, valid from 1 to 65535. Use 0 for undefined.
func NewPortFromString ¶
type PortAllocator ¶
type PortAllocator struct {
// contains filtered or unexported fields
}
An example of a very simple Port allocator.
func NewPortAllocator ¶
func NewPortAllocator(base string, min, max Port) *PortAllocator
func (*PortAllocator) Run ¶
func (p *PortAllocator) Run()
type PortReservation ¶
type PortReservation struct {
*PortAllocator
}
func (*PortReservation) AtomicReserveExternalPorts ¶
func (a *PortReservation) AtomicReserveExternalPorts(path string, ports, existing PortPairs) (PortPairs, error)
func (*PortReservation) ReleaseExternalPorts ¶
func (a *PortReservation) ReleaseExternalPorts(ports PortPairs) error
Click to show internal directories.
Click to hide internal directories.