Documentation
¶
Overview ¶
Package monoton is a highly scalable, single/multi node, human-readable, predictable and incremental unique id generator
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Configure ¶
Configure configures the monoton with the given generator and node. If you need to reset the node, then you have to reconfigure. If you do not configure the node then the node will be set to zero value.
Example ¶
package main
import (
"fmt"
"github.com/mustafaturan/monoton"
"github.com/mustafaturan/monoton/sequencer"
)
func main() {
s := sequencer.NewMillisecond() // has 4 bytes free space for a node
n := uint(19) // Base62 => J
monoton.Configure(s, n)
fmt.Println(monoton.Next()[12:])
}
Output: 000J
func Next ¶
func Next() string
Next generates next incremental unique identifier as Base62 The execution will return the following Bytes (B) for the known sequencer types:
Second: 16 B => 6 B (seconds) + 6 B (counter) + 4 B (node) Millisecond: 16 B => 8 B (milliseconds) + 4 B (counter) + 4 B (node) Nanosecond: 16 B => 11 B (nanoseconds) + 2 B (counter) + 3 B (node)
For byte size decisions please refer to docs/adrs/byte-sizes.md
Example ¶
package main
import (
"fmt"
"github.com/mustafaturan/monoton"
"github.com/mustafaturan/monoton/sequencer"
)
func main() {
s := sequencer.NewMillisecond()
n := uint(19)
monoton.Configure(s, n)
fmt.Println(len(monoton.Next()))
}
Output: 16
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package sequencer provides sequences based on `monotonic` time Time The `sequncer` package provides sequences based on the `monotonic` time which represents the absolute elapsed wall-clock time since some arbitrary, fixed point in the past.
|
Package sequencer provides sequences based on `monotonic` time Time The `sequncer` package provides sequences based on the `monotonic` time which represents the absolute elapsed wall-clock time since some arbitrary, fixed point in the past. |
Click to show internal directories.
Click to hide internal directories.