id

package
v0.0.0-...-c23f155 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gen

type Gen func() uint64

Gen generates the number uuid.

func StandardSnowFlakeID

func StandardSnowFlakeID(dataCenterID, machineID int64, now func() time.Time) (Gen, error)

The now function is easily to be affected by clock skew. Then the global and unique id is unstable. Deprecated: Please use the SnowFlakeID(datacenterID, machineID int64, now func() time.Time) (UUIDGen, error)

type NanoIDGen

type NanoIDGen func() string

func ClassicNanoID

func ClassicNanoID(length int) (NanoIDGen, error)

type UUIDGen

type UUIDGen interface {
	Number() uint64
	Str() string
}

func MonotonicNonZeroID

func MonotonicNonZeroID() (UUIDGen, error)

func SnowFlakeID

func SnowFlakeID(dataCenterID, machineID int64, now func() time.Time) (UUIDGen, error)

func XSnowFlakeID

func XSnowFlakeID(dataCenterID, machineID int64, now func() time.Time) (UUIDGen, error)

func XSnowFlakeIDByWorkerID

func XSnowFlakeIDByWorkerID(workerID int64, now func() time.Time) (UUIDGen, error)

Jump to

Keyboard shortcuts

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