id

package
v1.6.5-rc21 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithGenerator

func WithGenerator(ctx context.Context, g Generator) context.Context

func WithGeneratorContext

func WithGeneratorContext(g Generator) contextx.WithContext

func WithSFIDGenerator

func WithSFIDGenerator(ctx context.Context, g SFIDGenerator) context.Context

func WithSFIDGeneratorContext

func WithSFIDGeneratorContext(g SFIDGenerator) contextx.WithContext

Types

type Generator

type Generator interface {
	ID() (uint64, error)
}

func FromIP

func FromIP(ip net.IP) (Generator, error)

func FromLocalIP

func FromLocalIP() (Generator, error)

func GeneratorFromContext

func GeneratorFromContext(ctx context.Context) (Generator, bool)

func MustGeneratorFromContext

func MustGeneratorFromContext(ctx context.Context) Generator

type SFIDGenerator

type SFIDGenerator interface {
	MustGenSFID() types.SFID
	MustGenSFIDs(n int) types.SFIDs
}

func MustNewSFIDGenerator

func MustNewSFIDGenerator() SFIDGenerator

func MustNewSFIDGeneratorWithWorkerID

func MustNewSFIDGeneratorWithWorkerID(wid uint32) SFIDGenerator

func MustSFIDGeneratorFromContext

func MustSFIDGeneratorFromContext(ctx context.Context) SFIDGenerator

func NewSFIDGenerator

func NewSFIDGenerator() (SFIDGenerator, error)

func NewSFIDGeneratorWithWorkerID

func NewSFIDGeneratorWithWorkerID(wid uint32) (SFIDGenerator, error)

func SFIDGeneratorFromContext

func SFIDGeneratorFromContext(ctx context.Context) (SFIDGenerator, bool)

type SFIDGeneratorImpl

type SFIDGeneratorImpl struct{ *snowflake_id.Snowflake }

func (*SFIDGeneratorImpl) MustGenSFID

func (sfg *SFIDGeneratorImpl) MustGenSFID() types.SFID

func (*SFIDGeneratorImpl) MustGenSFIDs

func (sfg *SFIDGeneratorImpl) MustGenSFIDs(n int) types.SFIDs

Jump to

Keyboard shortcuts

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