snowflake

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EpochBegin     = int64(1704067200000) // 2024-01-01T00:00:00Z
	SeqShift       = 0
	SeqMask        = uint64(0xFFF)
	MachineIDShift = 12
	MachineIDMask  = uint64(0x3FF000)
	TimestampShift = 22
)

Variables

View Source
var DefaultGenerator = &Generator{}

Functions

This section is empty.

Types

type Generator

type Generator struct {
	MachineID uint32
	Sequence  uint32
}

func (*Generator) Next

func (g *Generator) Next() ID

func (*Generator) NextAt

func (g *Generator) NextAt(t time.Time) ID

func (*Generator) NextAtUnixMilli

func (g *Generator) NextAtUnixMilli(t int64) ID

type ID

type ID uint64

func From

func From(value any) ID

func FromParts

func FromParts(machineID uint32, seq uint32, unixMilli int64) ID

func New

func New() ID

func Zero

func Zero() ID

func (ID) IsZero

func (value ID) IsZero() bool

func (ID) Lowerbound

func (value ID) Lowerbound() ID

func (ID) MachineID

func (value ID) MachineID() uint32

func (ID) MarshalJSON

func (value ID) MarshalJSON() ([]byte, error)

func (ID) MarshalText

func (value ID) MarshalText() (b []byte, e error)

func (ID) Sequence

func (value ID) Sequence() uint32

func (ID) String

func (value ID) String() string

func (ID) Timestamp

func (value ID) Timestamp() time.Time

func (ID) ToSlice

func (value ID) ToSlice() []byte

func (*ID) UnmarshalJSON

func (value *ID) UnmarshalJSON(data []byte) error

func (*ID) UnmarshalText

func (value *ID) UnmarshalText(data []byte) error

func (ID) Upperbound

func (value ID) Upperbound() ID

func (ID) Valid

func (value ID) Valid() bool

Jump to

Keyboard shortcuts

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