idm

package
v2.0.0-...-ea1a7ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
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")
)

Functions

This section is empty.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL