snowflake

package
v0.0.0-...-6029cb0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DSN       string
	TableName string
	Epoch     int64
	Schema    string
}

Config configuration for distributed snowflake

type Snowflake

type Snowflake struct {
	*snowflakex.Node
	// contains filtered or unexported fields
}

Snowflake represents a distributed snowflake ID generator backed by PostgreSQL

func New

func New(ctx context.Context, config Config) (*Snowflake, error)

New creates a new distributed snowflake instance

func (*Snowflake) Close

func (s *Snowflake) Close()

Close releases resources

func (*Snowflake) Generate

func (s *Snowflake) Generate() int64

Generate creates and returns a unique snowflake ID It panics if the worker lease has expired to prevent ID collision.

func (*Snowflake) GetWorkerID

func (s *Snowflake) GetWorkerID() int64

GetWorkerID returns the current worker ID

Jump to

Keyboard shortcuts

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