allocator

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCannotShareKey = errors.New("services can't share key")

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(svc string, serviceIPFamily ipfamily.Family, ports []Port, sharingKey, backendKey string) ([]net.IP, error)

Allocate assigns any available and assignable IP to service.

func (*Allocator) AllocateFromPool

func (a *Allocator) AllocateFromPool(svc string, serviceIPFamily ipfamily.Family, poolName string, ports []Port, sharingKey, backendKey string) ([]net.IP, error)

AllocateFromPool assigns an available IP from pool to service.

func (*Allocator) Assign

func (a *Allocator) Assign(svc string, ips []net.IP, ports []Port, sharingKey, backendKey string) error

Assign assigns the requested ip to svc, if the assignment is permissible by sharingKey and backendKey.

func (*Allocator) Pool added in v0.3.0

func (a *Allocator) Pool(svc string) string

Pool 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(svc string) bool

Unassign frees the IP associated with service, if any.

type Port added in v0.6.0

type Port struct {
	Proto string
	Port  int
}

Port represents one port in use by a service.

func (Port) String added in v0.6.0

func (p Port) String() string

String returns a text description of the port.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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