idgenerator

package
v0.0.0-...-daf8b82 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnchorEpoch = int64(1451569374000) // 2015/12/31 21:42:54

	DataCenterBits  = uint(2)
	MaxDataCenterId = -1 ^ (-1 << DataCenterBits)

	NodeIdBits = uint(7)
	MaxNodeId  = -1 ^ (-1 << NodeIdBits)

	SequenceBits      = uint(15)
	NodeIdShift       = SequenceBits
	DataCenterIdShift = SequenceBits + NodeIdBits
	TimestampShift    = SequenceBits + NodeIdBits + DataCenterBits
	MaxSequence       = -1 ^ (-1 << SequenceBits)

	MaxBatchIds = 100000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IdGenerator

type IdGenerator interface {
	NextId() (int64, error)
	NextIds(num int) ([]int64, error)
}

func NewSnowflake

func NewSnowflake(nodeId, datacenterId int64) (IdGenerator, error)

Jump to

Keyboard shortcuts

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