snowflake

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultNodeNumber = int64(1) // Number range from 0 to 1023.

DefaultNodeNumber is the default node number used to initialize the ID Generator.

Functions

func Default

func Default() ident.Identifier

Default returns the global Snowflake ID Generator instance.

Types

type Generator

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

Generator represents a Snowflake-based ID Generator.

func New

func New(nodeNumber int64) (*Generator, error)

New creates a new Snowflake Generator with the specified node number. It returns a pointer to the Generator and an error if any.

func (Generator) Gen

func (i Generator) Gen() string

Gen generates and returns a new Snowflake ID as a string.

func (Generator) Name

func (i Generator) Name() string

Name returns the name of the Generator, which is "snowflake".

func (Generator) Size

func (i Generator) Size() int

Size returns the size of the generated Snowflake ID string.

func (Generator) Validate

func (i Generator) Validate(id string) bool

Validate checks if the provided ID string is a valid Snowflake ID.

Jump to

Keyboard shortcuts

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