Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AtomicGenerator ¶
type AtomicGenerator struct {
// contains filtered or unexported fields
}
Thread-safe ID generator. Can generate 2^22 (or 4 194 304) locally unique IDs per millisecond, before it wraps around and starts generating duplicates.
func NewAtomicGenerator ¶
func NewAtomicGenerator() AtomicGenerator
Create an atomic ID generator. The generator is thread-safe.
func (*AtomicGenerator) ID ¶
func (g *AtomicGenerator) ID() ID
func (*AtomicGenerator) IDFromTime ¶
func (g *AtomicGenerator) IDFromTime(ts time.Time) ID
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Non-thread-safe ID generator. Can generate 2^22 (or 4 194 304) locally unique IDs per millisecond, before it wraps around and starts generating duplicates.
func NewGenerator ¶
func NewGenerator() Generator
Create an ID generator. The generator is NOT thread-safe.
type ID ¶
type ID uint64
32 bits unix seconds + 32 bits sequence (where first 10 bits are milliseconds)
func Generate ¶
func Generate() ID
Atomically generates the next ID based on current time. Thread-safe.
func IDFromString ¶
func IDFromTime ¶
Atomically generates the next ID based on provided timestamp. Thread-safe.
func (ID) AppendBinary ¶
AppendBinary implements internal.BinaryAppender.
func (ID) AppendText ¶
AppendBinary implements internal.TextAppender.