feat: Add support for UUID Version 8 (RFC 9562)#178
feat: Add support for UUID Version 8 (RFC 9562)#178ashwingopalsamy wants to merge 5 commits intogoogle:masterfrom
Conversation
ashwingopalsamy
left a comment
There was a problem hiding this comment.
Hi @bormanp, apologies for the noise! I’d really appreciate it if you could take a look at this proposal when you have a moment. Thanks in advance! 🙏
|
any news ? uuid v8 really useful when need to store in db and have ordered records with uniq node id |
|
hi team, would appreciate your eyes on this proposal. @quartzmo / @bormanp / @noahdietz :) |
|
Hello 👋 Would appreciate some review here :) |
version8.go
Outdated
| timestamp := uint64(time.Now().UnixNano()) | ||
|
|
||
| timeMu.Lock() | ||
| defer timeMu.Unlock() |
There was a problem hiding this comment.
Can we release lock after the if below?
There was a problem hiding this comment.
Not like that. Drop defer, it's not needed after the if.
version8.go
Outdated
| } | ||
|
|
||
| // makeV8 generates a version 8 UUID using user-provided or random data for custom_a, custom_b, and custom_c. | ||
| func makeV8(uuid []byte, customA, customB, customC []byte) { |
There was a problem hiding this comment.
Ah yes! This wasn't supposed to be here. Removed it.
remove redundant function (dead code) and place the `sync.Mutex` lock after the `if` condition
|
any news? this feature is so required today |
|
hey @arlanram, its just that we're awaiting for review from maintainers. @quartzmo / @bormanp / @noahdietz / @pborman 👀 |
|
any news ? |
|
Hello, @quartzmo / @bormanp / @noahdietz / @pborman. Sorry for the noice. We'd really appreciate your review here. |
|
@vtolstov I'm just a random guest here |
|
gentle ping |
|
what's going, any updates? |
Changes
This adds support for generating UUID Version 8 as defined in RFC 9562. UUIDv8 is designed for custom or experimental use cases, allowing you to embed application-specific data while adhering to standard version and variant bits.
What’s included:
NewV8(): Generates a UUIDv8 with random values.NewV8FromReader(customA, customB, r): Allows custom values forcustom_a(48 bits) andcustom_b(12 bits) whilecustom_cfield (62 bits) is filled using a random source or secure fallback.NewV8TimeBased(r): A time-based variant ofUUIDv8that uses the current timestamp forcustom_a. It also includes a sequence number to ensure uniqueness when multiple UUIDs are generated in the same nanosecond.This addition completes support for all UUID versions in RFC 9562. Looking forward for your feedback, team!