Documentation
¶
Overview ¶
Package partid mints the globally unique identifiers that name a part on a backend.
A part's backend key must be unique across every writer that can ever touch a prefix, not just within one process: two engines over one shared prefix (an ownership handoff, a restore from a stale index, a rejoin after a lease loss) would otherwise mint the same key for different content and overwrite each other's objects. A local counter cannot provide that, so the id is minted from a timestamp plus randomness instead of derived from what a node happens to hold.
Index ¶
Constants ¶
const EncodedLen = 26
EncodedLen is the length of an ID in its textual form.
const Len = 16
Len is the size of an ID in bytes.
Variables ¶
var ErrInvalid = errors.New("invalid part id")
ErrInvalid is returned by Parse for anything that is not a canonical id.
Functions ¶
Types ¶
type ID ¶
ID identifies a part: a 48-bit big-endian unix-millisecond timestamp followed by 80 random bits, the ULID layout. Its ID.String form is base32, so lexicographic order over part prefixes still matches creation order — the engine relies on that for stable part ordering.
func New ¶
func New() ID
New mints a fresh ID. Safe for concurrent use.
Ids minted by one process are strictly increasing even within a millisecond: the entropy is incremented rather than redrawn, which keeps ordering total without weakening uniqueness against other writers (each millisecond still starts from a fresh random draw).
func Parse ¶
Parse decodes the canonical textual form. It is strict: only uppercase alphabet characters are accepted, and the leading digit must not overflow 128 bits, so encoding a parsed id reproduces the input byte for byte.
func (ID) AppendText ¶
AppendText implements encoding.TextAppender.