snowflake

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package snowflake provides a unique ID generation based on Twitter Snowflake algorithm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Settings

type Settings struct {
	Node int64
}

type Snowflake

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

Snowflake represents a Snowflake generator with a unique generator.

func New

func New(s Settings) *Snowflake

New creates a new Snowflake generator with a unique generator.

func (Snowflake) Gen

func (s Snowflake) Gen() string

Gen generates a new Snowflake ID as a string.

func (Snowflake) Name

func (s Snowflake) Name() string

Name returns the name of the generator.

func (Snowflake) Size

func (s Snowflake) Size() int

Size returns the bit size of the generated Snowflake ID.

func (Snowflake) Validate

func (s Snowflake) Validate(id string) bool

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

Jump to

Keyboard shortcuts

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