snowflake

package
v0.0.0-...-ee0865d Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIN_ID = 1000000000000000000 // 最小id

	NodeIdBits = uint(10) //节点 所占位置

)

Variables

This section is empty.

Functions

func ExtractNodeIdFromId

func ExtractNodeIdFromId(uuid64 int64) int64

func ExtractSequenceFromId

func ExtractSequenceFromId(uuid64 int64) int64

func ExtractTimestampFromId

func ExtractTimestampFromId(uuid64 int64) int64

ExtractTimestampFromId 输出时间戳

func ExtractYearFromId

func ExtractYearFromId(uuid64 int64) int

func ExtractYearMonthDayFromId

func ExtractYearMonthDayFromId(uuid64 int64) string

func ExtractYearMonthFromId

func ExtractYearMonthFromId(uuid64 int64) string

func RandInt

func RandInt(min, max int) int

Types

type IdWorker

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

func NewIdWorker

func NewIdWorker(NodeId int64) (*IdWorker, error)

NewIdWorker new a snowflake id generator object.

func (*IdWorker) GetLastTimestamp

func (id *IdWorker) GetLastTimestamp() int64

func (*IdWorker) GetNodeId

func (id *IdWorker) GetNodeId() int64

func (*IdWorker) GetSequence

func (id *IdWorker) GetSequence() int64

func (*IdWorker) NextId

func (id *IdWorker) NextId() (int64, error)

NextId get a snowflake id.

func (*IdWorker) NextIds

func (id *IdWorker) NextIds(num int) ([]int64, error)

NextIds get snowflake ids.

func (*IdWorker) TransferShortId

func (id *IdWorker) TransferShortId(uuid64 int64) int64

Jump to

Keyboard shortcuts

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