uid

package
v0.3.19 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIPWorkerID

func GetIPWorkerID(ip string) int

GetIPWorkerID gets the worker id with ip

func GetLocalIP

func GetLocalIP() string

GetLocalIP gets the local ip, it will get rid of the loop back ip

func GetRandWorkerID

func GetRandWorkerID() int

GetRandWorkerID gets the worker id with random number

func HashWorkerID

func HashWorkerID(data []byte) int

HashWorkerID gets the worker id with input data

func SetEpoch

func SetEpoch(t time.Time)

SetEpoch sets the epoch of uid generator, remember to set it before calling NewNode() function

func SetNodeBit

func SetNodeBit(nodeBits uint8)

SetNodeBits sets the node bits, remember to set it before calling NewNode() function

func SetStepBit

func SetStepBit(stepBits uint8)

SetStepBits sets the step bits, remember to set it before calling NewNode() function

Types

type Node

type Node struct {
	*snowflake.Node
}

func NewNode

func NewNode(nodeID int) (*Node, error)

NewNode returns *Node with given node id

func NewNodeWithDefault

func NewNodeWithDefault() (*Node, error)

NewNodeWithDefault returns *Node with default node id

func NewNodeWithIP

func NewNodeWithIP(ip string) (*Node, error)

NewNodeWithIP returns *Node with ip

func (*Node) GenerateID

func (n *Node) GenerateID() snowflake.ID

Generate generates a unique id

func (*Node) GenerateInt

func (n *Node) GenerateInt() int

GenerateInt generates a unique id with int type

func (*Node) GenerateString

func (n *Node) GenerateString() string

GenerateString generates a unique id with string type

func (*Node) GetNodeID

func (n *Node) GetNodeID() int

GetNodeID returns the node id of the node

Jump to

Keyboard shortcuts

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