Documentation ¶
Index ¶
- Variables
- type Allocator
- func (r *Allocator) Allocate(block uid.Block) error
- func (r *Allocator) AllocateNext() (uid.Block, error)
- func (r *Allocator) Free() int
- func (r *Allocator) Has(block uid.Block) bool
- func (r *Allocator) Release(block uid.Block) error
- func (r *Allocator) Restore(into *uid.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 *uid.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 block. ErrNotInRange or ErrAllocated will be returned if the block is not valid for this range or has already been reserved. ErrFull will be returned if there are no blocks left.
func (*Allocator) AllocateNext ¶
AllocateNext reserves one of the ports from the pool. ErrFull may be returned if there are no ports left.
func (*Allocator) Has ¶
Has returns true if the provided port is already allocated and a call to Allocate(block) 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.