snowflake

package
v0.0.1-alpha1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Epoch = 1730390400 // 元时间 2024-11-01 00:00:00

)

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID uint64

func ParseBytes

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

func ParseInt64

func ParseInt64(id int64) ID

func ParseString

func ParseString(id string) (ID, error)

func (ID) Base64

func (f ID) Base64() string

func (ID) Bytes

func (f ID) Bytes() []byte

func (ID) DataCenter

func (f ID) DataCenter() int64

func (ID) Int64

func (f ID) Int64() int64

func (ID) Node

func (f ID) Node() int64

func (ID) Sequence

func (f ID) Sequence() int64

func (ID) String

func (f ID) String() string

func (ID) Time

func (f ID) Time() int64

func (ID) Uint64

func (f ID) Uint64() uint64

type IDGenerator

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

IDGenerator 共享内存和锁的结构

func New

func New(dataCenterID, nodeID int64) (*IDGenerator, error)

New 初始化雪花 ID 生成器

func (*IDGenerator) NextID

func (g *IDGenerator) NextID() ID

NextID 获取新的 ID

Jump to

Keyboard shortcuts

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