uid

package
v0.0.0-...-9835270 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: AGPL-3.0, Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseTs    = 1530687318000 //2018/7/4 14:55:18
	SeqLen    = 12
	WorkerLen = 10

	WorkerMask = 1<<WorkerLen - 1
	SeqMask    = 1<<SeqLen - 1

	TsShift   = SeqLen + WorkerLen
	SeqShift  = WorkerLen
	MaxWorkId = 1<<WorkerLen - 1
	MaxSeq    = 1<<SeqLen - 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type UidGenerator

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

func NewDefaultIdGenerator

func NewDefaultIdGenerator(instanceID int) (*UidGenerator, error)

func NewIdGenerator

func NewIdGenerator(start, end int64) (*UidGenerator, error)

func (*UidGenerator) Next

func (idg *UidGenerator) Next() (id int64, err error)

type UidGeneratorMng

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

func GetUidGeneratorMng

func GetUidGeneratorMng() *UidGeneratorMng

func (*UidGeneratorMng) GetIdg

func (m *UidGeneratorMng) GetIdg(key string) *UidGenerator

func (*UidGeneratorMng) Register

func (m *UidGeneratorMng) Register(key string, start, end int64)

Jump to

Keyboard shortcuts

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