snowflake

package
v0.0.0-...-0b61f1f Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const BIT_BETWEEN_11_TO_0 = 0xFFF // Increment
View Source
const BIT_BETWEEN_16_TO_12 = 0x1F000 // Process ID
View Source
const BIT_BETWEEN_21_TO_17 = 0x3E0000 // DataCenter ID

TODO: Can be more flexible, Ref: bitwise operators setbit

Variables

This section is empty.

Functions

This section is empty.

Types

type Snowflake

type Snowflake struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(workerId int64, datacenterId int64) (*Snowflake, error)

func (*Snowflake) NextBase62Id

func (sf *Snowflake) NextBase62Id() (string, error)

func (*Snowflake) NextId

func (sf *Snowflake) NextId() (int64, error)

func (*Snowflake) RetrievalDatacenterId

func (sf *Snowflake) RetrievalDatacenterId(id int64) int64

func (*Snowflake) RetrievalSequence

func (sf *Snowflake) RetrievalSequence(id int64) int64

func (*Snowflake) RetrievalTimestamp

func (sf *Snowflake) RetrievalTimestamp(id int64) int64

func (*Snowflake) RetrievalWorkerId

func (sf *Snowflake) RetrievalWorkerId(id int64) int64

Jump to

Keyboard shortcuts

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