ident: system identifier generator

This is pretty fast and guarantees uniqueness when initialised correctly.

Signed-off-by: Yonah <contrib@gensokyo.uk>
This commit is contained in:
2026-03-22 22:22:04 +09:00
parent 22b8cc3884
commit 338cb1e000
5 changed files with 81 additions and 14 deletions

View File

@@ -17,17 +17,13 @@ const (
// S represents a unique system identifier.
type S struct {
// Deployment site, typically denoting a datacenter servicing a region.
Site uint32
// Servicing host behind load balancer, unique within its Site.
Host uint32
PartG
// An instant in time, some time after the corresponding system metadata
// first appeared to the backend, represented in nanoseconds since
// 1970-01-01.
Time uint64
// Randomly generated value. The implementation must guarantee that the same
// value cannot be emitted for a Time value on a servicing Host.
// value cannot be emitted for a Time value on a servicing host.
ID uint64
}