id

package
v1.1.0-beta.0...-604b0d6 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLabel is the default label for id allocator.
	DefaultLabel label = "idalloc"
	// KeyspaceLabel is the label for keyspace id allocator.
	KeyspaceLabel label = "keyspace-idAlloc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocator

type Allocator interface {
	// SetBase set base id
	SetBase(newBase uint64) error
	// Alloc allocs a unique id.
	Alloc() (uint64, error)
	// Rebase resets the base for the allocator from the persistent window boundary,
	// which also resets the end of the allocator. (base, end) is the range that can
	// be allocated in memory.
	Rebase() error
}

Allocator is the allocator to generate unique ID.

func NewAllocator

func NewAllocator(params *AllocatorParams) Allocator

NewAllocator creates a new ID Allocator.

type AllocatorParams

type AllocatorParams struct {
	Client *clientv3.Client
	Label  label  // Label used to label metrics and logs.
	Member string // Member value, used to check if current pd leader.
	Step   uint64 // Step size of each persistent window boundary increment, default 1000.
}

AllocatorParams are parameters needed to create a new ID Allocator.

Jump to

Keyboard shortcuts

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