Documentation ¶
Overview ¶
Package uid @Title fakeid.go @Description @Author haogooder @Update 2022/2/8
Package uid @Title snowflake.go @Description @Author haogooder @Update 2022/2/8
Index ¶
- Variables
- func FakeTraceId() (traceId string)
- type SnowFlakeIdGenerator
- func (sfg *SnowFlakeIdGenerator) Init() (*SnowFlakeIdGenerator, error)
- func (sfg *SnowFlakeIdGenerator) NextId() (int64, error)
- func (sfg *SnowFlakeIdGenerator) Parse(id int64) (int64, int64, int64, error)
- func (sfg *SnowFlakeIdGenerator) SetSequenceBitSize(n uint8) *SnowFlakeIdGenerator
- func (sfg *SnowFlakeIdGenerator) SetTimeBitSize(n uint8) *SnowFlakeIdGenerator
- func (sfg *SnowFlakeIdGenerator) SetWorkerId(w int64) *SnowFlakeIdGenerator
- func (sfg *SnowFlakeIdGenerator) SetWorkerIdBitSize(n uint8) *SnowFlakeIdGenerator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( LocalHostIP = "" LocalHostIpArr []string LocalHostIpTraceId = "" SequenceIDGenerator SnowFlakeIdGenerator ScreenWidth int ScreenHeight int )
Functions ¶
Types ¶
type SnowFlakeIdGenerator ¶
type SnowFlakeIdGenerator struct {
// contains filtered or unexported fields
}
SnowFlake的结构体
func (*SnowFlakeIdGenerator) Init ¶
func (sfg *SnowFlakeIdGenerator) Init() (*SnowFlakeIdGenerator, error)
初始化操作
func (*SnowFlakeIdGenerator) NextId ¶
func (sfg *SnowFlakeIdGenerator) NextId() (int64, error)
生成下一个ID
func (*SnowFlakeIdGenerator) SetSequenceBitSize ¶
func (sfg *SnowFlakeIdGenerator) SetSequenceBitSize(n uint8) *SnowFlakeIdGenerator
设置序号占的位数
func (*SnowFlakeIdGenerator) SetTimeBitSize ¶
func (sfg *SnowFlakeIdGenerator) SetTimeBitSize(n uint8) *SnowFlakeIdGenerator
设置时间戳占的位数
func (*SnowFlakeIdGenerator) SetWorkerId ¶
func (sfg *SnowFlakeIdGenerator) SetWorkerId(w int64) *SnowFlakeIdGenerator
设置worker id
func (*SnowFlakeIdGenerator) SetWorkerIdBitSize ¶
func (sfg *SnowFlakeIdGenerator) SetWorkerIdBitSize(n uint8) *SnowFlakeIdGenerator
设置worker id占的位数
Click to show internal directories.
Click to hide internal directories.