allocator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocator

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

An Allocator tracks IP address pools and allocates addresses from them.

func New

func New() *Allocator

New returns an Allocator managing no pools.

func (*Allocator) Allocate

func (a *Allocator) Allocate(service string) (net.IP, error)

Allocate assigns any available IP to service.

func (*Allocator) AllocateFromPool

func (a *Allocator) AllocateFromPool(service, pool string) (net.IP, error)

AllocateFromPool assigns an available IP from pool to service.

func (*Allocator) Assign

func (a *Allocator) Assign(service string, ip net.IP) error

Assign marks service as the owner of ip, if that address is available.

func (*Allocator) GetIP

func (a *Allocator) GetIP(service string) net.IP

GetIP returns the IP address allocated to service, or nil if none are allocated.

func (*Allocator) GetPool

func (a *Allocator) GetPool(service string) string

GetPool returns the pool from which service's IP was allocated. If service has no IP allocated, "" is returned.

func (*Allocator) SetPools

func (a *Allocator) SetPools(pools map[string]*config.Pool) error

SetPools updates the set of address pools that the allocator owns.

func (*Allocator) Unassign

func (a *Allocator) Unassign(service string) bool

Unassign frees the IP associated with service, if any.

Jump to

Keyboard shortcuts

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