snowflake

package
v0.0.0-...-139fbb7 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxDatacenterID = -1 ^ (-1 << datacenterIDBits)
	MaxWorkerID     = -1 ^ (-1 << workerIDBits)
	MaxSequence     = -1 ^ (-1 << sequenceBits)
)

Variables

View Source
var (
	ErrClockMovingBackwards   = errors.New("the clock is moving backwards")
	ErrDatacenterIDOutOfRange = fmt.Errorf("datacenter id is out of range [0, %d]", MaxDatacenterID)
	ErrWorkerIDOutOfRange     = fmt.Errorf("worker id is out of range [0, %d]", MaxWorkerID)
)

Functions

This section is empty.

Types

type Generator

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

func NewGenerator

func NewGenerator(clock clock.Clock, datacenterID, workerID uint32) (*Generator, error)

func (*Generator) Generate

func (g *Generator) Generate() (ID, error)

type ID

type ID uint64

func (ID) DatacenterID

func (s ID) DatacenterID() uint32

func (ID) Sequence

func (s ID) Sequence() uint32

func (ID) Timestamp

func (s ID) Timestamp() int64

func (ID) WorkerID

func (s ID) WorkerID() uint32

Jump to

Keyboard shortcuts

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