uid

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: MIT Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var (
	LocalHostIP         = ""
	LocalHostIpArr      []string
	LocalHostIpTraceId  = ""
	SequenceIDGenerator SnowFlakeIdGenerator

	ScreenWidth  int
	ScreenHeight int
)

Functions

func FakeTraceId

func FakeTraceId() (traceId string)

生成一个假的traceId

Types

type SnowFlakeIdGenerator

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

SnowFlake的结构体

func NewIDGenerator

func NewIDGenerator() *SnowFlakeIdGenerator

实例化一个ID生成器

func (*SnowFlakeIdGenerator) Init

初始化操作

func (*SnowFlakeIdGenerator) NextId

func (sfg *SnowFlakeIdGenerator) NextId() (int64, error)

生成下一个ID

func (*SnowFlakeIdGenerator) Parse

func (sfg *SnowFlakeIdGenerator) Parse(id int64) (int64, int64, 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占的位数

Jump to

Keyboard shortcuts

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