snowflake

package module
v0.0.0-...-34d6fe6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

README

go-snowflake

介绍

Go 版分布式系统生成唯一ID算法(Snowflake)

download
go get gitee.com/lingdun/go-snowflake

例子请看 snowflake_test.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IdWorker

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

func NewIdWorker

func NewIdWorker(workerId, dataCenterId, epoch int64) (error, *IdWorker)

NewIdWorker new worker

func (*IdWorker) GenTime

func (i *IdWorker) GenTime() int64

GenTime 获取当前时间, 单位是毫秒

func (*IdWorker) GetDataCenterID

func (i *IdWorker) GetDataCenterID() int64

GetDataCenterID 获得datacenterID

func (*IdWorker) GetWorkerId

func (i *IdWorker) GetWorkerId() int64

GetWorkerId 获得workerID

func (*IdWorker) NextId

func (i *IdWorker) NextId() (error, int64)

NextId 生成一个ID

Jump to

Keyboard shortcuts

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