Documentation ¶
Index ¶
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 *NetIDRange, allocatorFactory allocator.AllocatorFactory) *Allocator
New creates a Allocator over a netid Range, calling allocatorFactory to construct the backing store.
func NewInMemory ¶
func NewInMemory(r *NetIDRange) *Allocator
Helper that wraps New, for creating a range backed by an in-memory store.
func (*Allocator) Allocate ¶
Allocate attempts to reserve the provided netid. ErrNotInRange or ErrAllocated will be returned if the netid is not valid for this range or has already been reserved.
func (*Allocator) AllocateNext ¶
AllocateNext reserves one of the netids from the pool. ErrFull may be returned if there are no netids left.
type Interface ¶
type Interface interface { Allocate(uint32) error AllocateNext() (uint32, error) Release(uint32) error Has(uint32) bool }
Interface manages the allocation of netids out of a range. Interface should be threadsafe.
type NetIDRange ¶
func NewNetIDRange ¶
func NewNetIDRange(min, max uint32) (*NetIDRange, error)
func (*NetIDRange) Contains ¶
func (r *NetIDRange) Contains(netid uint32) (bool, uint32)
Contains tests whether a given netid falls within the Range.
func (*NetIDRange) Set ¶
func (r *NetIDRange) Set(base, size uint32) error
func (*NetIDRange) String ¶
func (r *NetIDRange) String() string
Click to show internal directories.
Click to hide internal directories.