Documentation
¶
Overview ¶
Package id generates prefixed, time-ordered identifiers. IDs encode a millisecond timestamp and per-timestamp counter in six big-endian bytes, followed by 14 modulo-biased base62 characters.
Index ¶
- func Ascending(kind string, given ...string) (string, error)
- func Create(prefix string, direction Direction, timestamp ...int64) (string, error)
- func Descending(kind string, given ...string) (string, error)
- func Prefix(kind string) (string, bool)
- func SchemaAccepts(kind, value string) bool
- func Timestamp(value string) (int64, error)
- type Direction
- type Generator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ascending ¶
Ascending returns an ascending ID for kind. An absent or empty given value generates a new ID; any other value is prefix-checked and returned verbatim.
func Descending ¶
Descending returns a descending ID for kind; given is handled as in Ascending.
func SchemaAccepts ¶
SchemaAccepts reports whether value carries the prefix for kind.
Types ¶
type Direction ¶
type Direction string
Direction selects the timestamp byte ordering used by Create.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator owns the monotonic counter and its injectable side effects.
func NewGenerator ¶
NewGenerator constructs an independent ID generator. Nil inputs use the wall clock and crypto/rand.