reckon_gater_uuid (reckon_gater v1.3.0)
View SourceUUIDv7 generator — time-sortable unique identifiers.
UUIDv7 encodes a Unix timestamp in milliseconds in the high 48 bits, followed by version/variant markers and 62 bits of randomness. This makes IDs naturally time-ordered, which is ideal for event stores.
Format (128 bits): 48 bits: unix_ts_ms (milliseconds since epoch) 4 bits: version (0111 = 7) 12 bits: rand_a 2 bits: variant (10) 62 bits: rand_b
Reference: RFC 9562, Section 5.7
Summary
Functions
Parse a UUID string back to 16-byte binary.
Extract the Unix timestamp (milliseconds) from a UUIDv7.
Generate a new UUIDv7 directly as a formatted string.
Format a 16-byte UUID binary as a lowercase hex string with dashes.
Generate a new UUIDv7 as a 16-byte binary.
Functions
Parse a UUID string back to 16-byte binary.
-spec timestamp_ms(<<_:128>>) -> non_neg_integer().
Extract the Unix timestamp (milliseconds) from a UUIDv7.
-spec to_binary(<<_:128>>) -> binary().
Generate a new UUIDv7 directly as a formatted string.
-spec to_string(<<_:128>>) -> binary().
Format a 16-byte UUID binary as a lowercase hex string with dashes.
-spec v7() -> <<_:128>>.
Generate a new UUIDv7 as a 16-byte binary.