id

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HostIDBits      = 8
	TimeBits        = 48
	IncrementorBits = 8
)

bit counts.

Variables

This section is empty.

Functions

func GenShort

func GenShort() int64

GenShort returns a 64 bit id. The first 8 bits are from the server id The next 48 bits are from the timestamp with microsecond precision The last 8 bits are from an incrementor

func HostID

func HostID() int64

HostID returns the host ID for the current machine. The first bit is always 0

func SetHostID

func SetHostID(hostid int64)

func ShortTimeReset

func ShortTimeReset() (last time.Time, next time.Time)

ShortTimeReset the current bounds of validity for timestamps extracted from shorts

func SplitShort

func SplitShort(s int64) (hostID int64, createdAt time.Time, incrementor int64)

SplitShort extracts information from the short ID The time parameter may only be useful if the ID was created in the latest 9 year interval (see ShortTimeReset).

Types

This section is empty.

Jump to

Keyboard shortcuts

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