package idm

import "github.com/moby/swarmkit/v2/internal/idm"

Package idm manages reservation/release of numerical ids from a configured set of contiguous ids.

Index

Variables

var (
	// ErrNoBitAvailable is returned when no more bits are available to set
	ErrNoBitAvailable = errors.New("no bit available")
	// ErrBitAllocated is returned when the specific bit requested is already set
	ErrBitAllocated = errors.New("requested bit is already allocated")
)

Types

type IDM

type IDM struct {
	// contains filtered or unexported fields
}

IDM manages the reservation/release of numerical ids from a contiguous set.

An IDM instance is not safe for concurrent use.

func New

func New(start, end uint) (*IDM, error)

New returns an instance of id manager for a [start,end] set of numerical ids.

func (*IDM) GetID

func (i *IDM) GetID(serial bool) (uint, error)

GetID returns the first available id in the set.

func (*IDM) GetSpecificID

func (i *IDM) GetSpecificID(id uint) error

GetSpecificID tries to reserve the specified id.

func (*IDM) Release

func (i *IDM) Release(id uint)

Release releases the specified id.

Source Files

idm.go

Version
v2.0.0-20250103191802-8c1959736554 (latest)
Published
Jan 3, 2025
Platform
linux/amd64
Imports
3 packages
Last checked
2 weeks ago

Tools for package owners.