snowflake

package module
v0.0.0-...-68123c9 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: MIT Imports: 6 Imported by: 0

README

Based on tiwtter algorithm snowflake github.com/twitter/snowflake in golang

License

MIT Licence

Documentation

Index

Constants

View Source
const (
	WorkerIdBits = 10              // worker id
	MaxWorkerId  = -1 ^ (-1 << 10) // worker id mask
	SequenceBits = 12              // sequence
	MaxSequence  = -1 ^ (-1 << 12) //sequence mask
)

Variables

View Source
var (
	Since int64 = time.Date(2012, 1, 0, 0, 0, 0, 0, time.UTC).UnixNano() / nano
)

Functions

func DefaultWorkId

func DefaultWorkId() uint32

Types

type SnowFlake

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

func Default

func Default() (*SnowFlake, error)

func NewSnowFlake

func NewSnowFlake(workerId uint32) (*SnowFlake, error)

func (*SnowFlake) Next

func (sf *SnowFlake) Next() (uint64, error)

Jump to

Keyboard shortcuts

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