snowflake32

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Snowflake

type Snowflake struct {
	sync.Mutex // 锁
	// contains filtered or unexported fields
}

Snowflake 24小时内不会重复的雪花序号生成器 构成为: 0 | seconds 17 bit | datacenter 2 bit | worker 3 bit| sequence 9 bit 最大支持32个节点,单节点TPS不超过512,超过则会阻塞程序到下一秒再返回序号,仅能用于特殊场景 seconds占用17bits是因为一天86400秒占用17bits

func NewSnowflake

func NewSnowflake(d int32, w int32) *Snowflake

NewSnowflake d for datacenter-id, w for worker-id

func (*Snowflake) NextVal

func (s *Snowflake) NextVal() int32

func (*Snowflake) String

func (s *Snowflake) String() string

Jump to

Keyboard shortcuts

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