Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Default = Flaker(&flaker{ mutex: &sync.Mutex{}, machineId: byte(getLocalIPv4() & machineIdMask), epochStart: 1577833200000000000, })
Default is the default singleton of Flaker with sets the lower 8 bits of the first non loopback IPv4 address (zero if not available) as machine-id and the 1/1/2020 as epoch start (epoch is only needed for sortable IDs).
Functions ¶
This section is empty.
Types ¶
type Flake ¶
type Flake int64
Flake represents a unique 63 bit ID.
type Flaker ¶
type Flaker interface { Next() Flake WithMachineId(machineId byte) Flaker WithEpochStart(time time.Time) Flaker }
Flaker is the generator interface.
func WithEpochStart ¶
WithEpochStart is a shorthand for Default.WithEpochStart(time)
func WithMachineId ¶
WithMachineId is a shorthand for Default.WithMachineId(machineId)
Click to show internal directories.
Click to hide internal directories.