id

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTxnPutEndID         = coderr.NewCodeError(coderr.Internal, "put end id in txn")
	ErrAllocID             = coderr.NewCodeError(coderr.Internal, "alloc id")
	ErrCollectID           = coderr.NewCodeError(coderr.Internal, "collect invalid id")
	ErrCollectNotSupported = coderr.NewCodeError(coderr.Internal, "collect is not supported")
)

Functions

This section is empty.

Types

type Allocator

type Allocator interface {
	// Alloc allocs a unique id.
	Alloc(ctx context.Context) (uint64, error)

	// Collect collect unused id to reused in alloc
	Collect(ctx context.Context, id uint64) error
}

Allocator defines the id allocator on the ceresdb cluster meta info.

func NewAllocatorImpl

func NewAllocatorImpl(logger *zap.Logger, kv clientv3.KV, key string, allocStep uint) Allocator

func NewReusableAllocatorImpl added in v0.4.0

func NewReusableAllocatorImpl(existIDs []uint64, minID uint64) Allocator

type AllocatorImpl

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

func (*AllocatorImpl) Alloc

func (a *AllocatorImpl) Alloc(ctx context.Context) (uint64, error)

func (*AllocatorImpl) Collect added in v0.4.0

func (a *AllocatorImpl) Collect(_ context.Context, _ uint64) error

type OrderedList added in v0.4.0

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

func (*OrderedList) FindMinHoleValueAndIndex added in v0.4.0

func (l *OrderedList) FindMinHoleValueAndIndex(min uint64) (uint64, int)

FindMinHoleValueAndIndex Find the minimum hole value and its index. If the list is empty, then return min value and 0 as index; If no hole is found, then return the `last_value + 1` in the list and l.Len() as the index;

func (*OrderedList) Insert added in v0.4.0

func (l *OrderedList) Insert(v uint64, i int)

Insert the value at the idx whose correctness should be ensured by the caller.

func (*OrderedList) Remove added in v0.4.0

func (l *OrderedList) Remove(v uint64) int

type ReusableAllocatorImpl added in v0.4.0

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

func (*ReusableAllocatorImpl) Alloc added in v0.4.0

func (*ReusableAllocatorImpl) Collect added in v0.4.0

func (a *ReusableAllocatorImpl) Collect(_ context.Context, id uint64) error

Jump to

Keyboard shortcuts

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