zuid

package
v1.0.80 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bits

type Bits struct {
	Rand int64 // 随机位数
	Time int64 // 时间位数
	Node int64 // 节点位数
	Step int64 // 序列位数
}

func NewBits

func NewBits(rand, time, node, step int64) Bits

func (Bits) Total

func (b Bits) Total() int64

type ID

type ID int64

func (ID) Bytes

func (id ID) Bytes() []byte

func (ID) Int64

func (id ID) Int64() int64

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

func (ID) String

func (id ID) String() string

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) (err error)

type Node

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

func NewNode

func NewNode(epoch, ms, node int64, bits Bits, sort Sort) *Node

func Shotflake

func Shotflake(epoch, node int64) *Node

短ID雪花算法

func Snowflake

func Snowflake(epoch, node int64) *Node

标准雪花算法 - Twitter

func Sonyflake

func Sonyflake(epoch, node int64) *Node

索尼雪花算法

func (*Node) GenID

func (n *Node) GenID() ID

type Sort

type Sort struct {
	Rand int64 // 随机位权重
	Time int64 // 时间位权重
	Node int64 // 节点位权重
	Step int64 // 序列位权重
}

func NewSort

func NewSort(rand, time, node, step int64) Sort

func (Sort) Count

func (s Sort) Count() int

Jump to

Keyboard shortcuts

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