OrderlyID offers a typed, time-sortable identifier format that enhances safety and developer ergonomics. With built-in fields for tenancy and optional checksums, it improves upon traditional UUIDs and AUTO_INCREMENT by enabling efficient ID generation in distributed systems and public APIs, all while retaining a human-readable format.
OrderlyID is a sophisticated identifier format designed for modern distributed systems, providing a typed, time-sortable globally unique identifier with optional checksum and fields for tenancy and sharding. It addresses the common pitfalls associated with existing solutions like UUIDv4 and INT IDs, enhancing both safety and developer ergonomics in public APIs, logs, and distributed environments.
order_... or user_..., improving context in logs and making it easier to identify the nature of each ID.Against AUTO_INCREMENT:
Against UUIDv4:
shipment_...) as opposed to random hex values.An OrderlyID adheres to the canonical format:
<prefix>_<payload>[-<checksum>]
order) representing the entity type, followed by a required underscore separator.Example:
order_00myngy59c0003000dfk59mg3e36j3rr-9xgg
The binary layout consists of time, flags, tenant, sequence, shard, and randomness, offering flexibility and robust data integrity.
OrderlyID can be implemented using the provided reference Go library:
import "github.com/kpiljoong/orderlyid"
id := orderlyid.New("order",
orderlyid.WithTenant(12),
orderlyid.WithShardFromBytes([]byte("customer")),
orderlyid.WithChecksum(true),
)
// => "order_00myngy59c0003000dfk59mg3e36j3rr-9xgg"
A reference implementation in Go is currently available and production-ready. Planned language bindings for Rust and Python are in the roadmap, along with enhancements and contributions from the community are welcome.
OrderlyID aims to provide a modern, ergonomic solution for identifiers, ensuring easier, safer, and more efficient identification in today's complex software systems.
No comments yet.
Sign in to be the first to comment.