port_allocator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2016 License: Apache-2.0 Imports: 7 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 OverwriteableFile

type OverwriteableFile interface {
	io.Reader
	io.Writer
	io.Seeker
	Truncate(size int64) error
}

type Pool

type Pool struct {
	AcquiredPorts map[int]bool
}

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 serializer
	Locker     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 Serializer

type Serializer struct{}

func (*Serializer) DecodeAll

func (s *Serializer) DecodeAll(file io.ReadSeeker, outData interface{}) error

func (*Serializer) EncodeAndOverwrite

func (s *Serializer) EncodeAndOverwrite(file OverwriteableFile, outData interface{}) error

type Tracker

type Tracker struct {
	Logger    lager.Logger
	StartPort int
	Capacity  int
}

func (*Tracker) AcquireOne

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

func (*Tracker) InRange

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

func (*Tracker) ReleaseMany

func (t *Tracker) ReleaseMany(pool *Pool, toRelease []int) error

Jump to

Keyboard shortcuts

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