port_allocator

package
v0.0.0-...-410f0c4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorPortPoolExhausted = errors.New("port pool exhausted")

Functions

This section is empty.

Types

type Pool

type Pool struct {
	AcquiredPorts map[int]string
}

func (*Pool) MarshalJSON

func (p *Pool) MarshalJSON() ([]byte, error)

func (*Pool) UnmarshalJSON

func (p *Pool) UnmarshalJSON(bytes []byte) error

type PortAllocator

type PortAllocator struct {
	Tracker    tracker
	Serializer serial.Serializer
	Locker     filelock.FileLocker
}

func (*PortAllocator) AllocatePort

func (p *PortAllocator) AllocatePort(handle string, port int) (int, error)

func (*PortAllocator) ReleaseAllPorts

func (p *PortAllocator) ReleaseAllPorts(handle string) error

type Tracker

type Tracker struct {
	StartPort int
	Capacity  int
}

func (*Tracker) AcquireOne

func (t *Tracker) AcquireOne(pool *Pool, handler string) (int, error)

func (*Tracker) InRange

func (t *Tracker) InRange(port int) bool

func (*Tracker) ReleaseAll

func (t *Tracker) ReleaseAll(pool *Pool, handle string) error

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.
fakes
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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