id

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

* @Descripttion: * @version: * @Author: lfzxs@qq.com * @Date: 2022-11-28 17:44:53 * @LastEditors: lfzxs@qq.com * @LastEditTime: 2022-11-29 17:23:46

* @Descripttion: 雪花ID * @version: * @Author: lfzxs@qq.com * @Date: 2022-11-29 08:58:29 * @LastEditors: lfzxs@qq.com * @LastEditTime: 2022-11-29 16:30:37

* @Descripttion: UUID * @version: * @Author: lfzxs@qq.com * @Date: 2022-11-29 08:55:02 * @LastEditors: lfzxs@qq.com * @LastEditTime: 2022-11-29 16:45:22

Index

Constants

View Source
const (
	// 结点idkey
	Nodeid_key = "nodeid"
	// 默认结点ID
	Default_nodeId = int64(1)
)

Variables

This section is empty.

Functions

func GetDefauleNodeId

func GetDefauleNodeId(pairs []types.Pair) int64

func Regist

func Regist(name string, IdGen IdGenerator) error

注册

func Replace

func Replace(name string, IdGen IdGenerator) error

替换

func UnRegist

func UnRegist(name string) error

注销

func WithNodeID

func WithNodeID(v int64) (p types.Pair)

Types

type IdGenerator

type IdGenerator interface {
	// 生成器名称
	GetName() string

	// 生成id
	GenId(pairs ...types.Pair) string
}

ID生成器

func Get

func Get(name string) (IdGenerator, bool)

获取

func Instance

func Instance(name string) IdGenerator

type SnowflakeID

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

雪花id

func CreateSnowflake

func CreateSnowflake(nodeid int64) SnowflakeID

创建一个雪花id生成器

func (*SnowflakeID) GenId

func (self *SnowflakeID) GenId(pairs ...types.Pair) string

func (*SnowflakeID) GetName

func (self *SnowflakeID) GetName() string

func (*SnowflakeID) SnowflakeId

func (self *SnowflakeID) SnowflakeId(pairs ...types.Pair) int64

type Uuid

type Uuid struct {
}

func (*Uuid) GenId

func (self *Uuid) GenId(pairs ...types.Pair) string

func (*Uuid) GetName

func (self *Uuid) GetName() string

Jump to

Keyboard shortcuts

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