Documentation ¶
Index ¶
- Variables
- type Allocator
- func (r *Allocator) Allocate(label *mcs.Label) error
- func (r *Allocator) AllocateNext() (*mcs.Label, error)
- func (r *Allocator) Free() int
- func (r *Allocator) Has(label *mcs.Label) bool
- func (r *Allocator) Release(label *mcs.Label) error
- func (r *Allocator) Restore(into *mcs.Range, data []byte) error
- func (r *Allocator) Snapshot(dst *api.RangeAllocation) error
- type Interface
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Allocator ¶
type Allocator struct {
// contains filtered or unexported fields
}
func New ¶
func New(r *mcs.Range, factory allocator.AllocatorFactory) *Allocator
New creates a Allocator over a UID range, calling factory to construct the backing store.
func NewInMemory ¶
NewInMemory creates an in-memory Allocator
func (*Allocator) Allocate ¶
Allocate attempts to reserve the provided label. ErrNotInRange or ErrAllocated will be returned if the label is not valid for this range or has already been reserved. ErrFull will be returned if there are no labels left.
func (*Allocator) AllocateNext ¶
AllocateNext reserves one of the labels from the pool. ErrFull may be returned if there are no labels left.
func (*Allocator) Has ¶
Has returns true if the provided port is already allocated and a call to Allocate(label) would fail with ErrAllocated.
func (*Allocator) Release ¶
Release releases the port back to the pool. Releasing an unallocated port or a port out of the range is a no-op and returns no error.