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 ¶
var (
ErrFull = errors.New("range is full")
ErrNotInRange = errors.New("provided UID range is not in the valid range")
ErrAllocated = errors.New("provided UID range is already allocated")
ErrMismatchedRange = errors.New("the provided UID range does not match the current UID range")
)
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 ¶
func NewInMemory(r *uid.Range) *Allocator
NewInMemory creates an in-memory Allocator
func (*Allocator) Allocate ¶
func (r *Allocator) Allocate(block uid.Block) error
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 ¶
func (r *Allocator) AllocateNext() (uid.Block, error)
AllocateNext reserves one of the ports from the pool. ErrFull may be returned if there are no ports left.
func (*Allocator) Free ¶
func (r *Allocator) Free() int
Free returns the count of port left in the range.
func (*Allocator) Has ¶
func (r *Allocator) Has(block uid.Block) bool
Has returns true if the provided port is already allocated and a call to Allocate(block) would fail with ErrAllocated.
func (*Allocator) Release ¶
func (r *Allocator) Release(block uid.Block) error
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.