Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add custom node ids #107

Open
wants to merge 65 commits into
base: master
Choose a base branch
from
Open

Conversation

tkarrass
Copy link

@tkarrass tkarrass commented Oct 3, 2022

In the current implementation, the generation of version 1 UUIDs using distinct node ids is only possible by sequentially calling "SetNodeID(…); NewUUID()" for each UUID to generate.
There also is no sort of locking for this workflow, so we might experience race conditions when generating UUIDs for distinct node ids simultaneously.

Additionally RFC-4122 section 4.5 suggests to set the u/m bit to 1, when using custom node ids in order to reliably avoid collisions with UUIDs created for node ids which are based on IEEE 802 addresses. This is not (and should not being) checked within the global SetNodeID(...) func.

So I decided to add a CustomNodeId type which enables this kind of usage in a clean way.

@tkarrass
Copy link
Author

tkarrass commented Nov 2, 2022

knock knock neo …

@tkarrass tkarrass requested a review from a team as a code owner December 1, 2023 16:36
Kerrigan29a and others added 28 commits September 11, 2024 13:28
Fix reamde to no longer say this is experimental.
The API is not going to change.
{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Resolves issue google#24
* Resolved code issues of gofmt and golint

Code quality: https://goreportcard.com/report/github.com/google/uuid

* Fix typo

* Update comment
Now it's easier to set breakpoint on error for debugging.
* Fixed race in NewUUID()

* Remove unnecessary variable
…oogle#69)

* Add benchmarks for different kinds of invalid UUIDs

Also add a test case for too-short UUIDs to ensure behavior doesn’t
change.

* Use a custom error type for invalid lengths, replacing `fmt.Errorf`

This significantly improves the speed of failed parses due to wrong
lengths. Previously the `fmt.Errorf` call dominated, making this the
most expensive error and more expensive than successfully parsing:

    BenchmarkParse-4                 29226529        36.1 ns/op
    BenchmarkParseBadLength-4         6923106       174 ns/op
    BenchmarkParseLen32Truncated-4   26641954        38.1 ns/op
    BenchmarkParseLen36Corrupted-4   19405598        59.5 ns/op

When the formatting is not required and done on-demand, the failure per
se is much faster:

    BenchmarkParse-4                 29641700        36.3 ns/op
    BenchmarkParseBadLength-4        58602537        20.0 ns/op
    BenchmarkParseLen32Truncated-4   30664791        43.6 ns/op
    BenchmarkParseLen36Corrupted-4   18882410        61.9 ns/op
Zero allocation by using non-pointer error.

related google#69

name               old time/op    new time/op    delta
ParseBadLength-16    15.4ns ± 0%     3.5ns ± 0%   ~     (p=1.000 n=1+1)

name               old alloc/op   new alloc/op   delta
ParseBadLength-16     8.00B ± 0%     0.00B        ~     (p=1.000 n=1+1)

name               old allocs/op  new allocs/op  delta
ParseBadLength-16      1.00 ± 0%      0.00        ~     (p=1.000 n=1+1)
Added a single period so that the documentation doesn't look weird. Boy, I hope the tests pass.
* hash.go hash error covered and linter error fixed

Error covered without change function definition

* Update hash.go
* added utility func

* updated docs & function call
cwlowder and others added 27 commits September 11, 2024 13:30
Updates the README to fix the link to the RFC. Fixes google#92.
This PR replaces `godoc.org` with `pkg.go.dev` in README.
* feat: add uuid slice type with strings convenience method

* test: benchmark new UUIDs.Strings() feature

* docs: improve comments on UUIDs

* fix: typos in UUIDs strings benchmark
🤖 I have created a release *beep* *boop*
---


## [1.4.0](https://togithub.com/google/uuid/compare/v1.3.1...v1.4.0) (2023-10-26)


### Features

* UUIDs slice type with Strings() convenience method ([google#133](https://togithub.com/google/uuid/issues/133)) ([cd5fbbd](https://togithub.com/google/uuid/commit/cd5fbbdd02f3e3467ac18940e07e062be1f864b4))

### Fixes

* Clarify that Parse's job is to parse but not necessarily validate strings. (Documents current behavior)

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
* add uuid version 6 and 7

* fix comment
* feat: Validate UUID without creating new UUID

* fix: update comment
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* Monotonicity in UUIDv7

* fix Monotonicity

* fix comment

* Monotonicity 2

* lock

* fix comment

* fix comment
* The top level permission for github workflows were set to be content
read

Signed-off-by: Joyce Brum <[email protected]>
)

* TestVersion7MonotonicityStrict

* reset timeNow and rand
* fix to use MustParse

* use MustParse(...)  inseted of Must(Parse(...))

---------

Co-authored-by: Noah Dietz <[email protected]>
Co-authored-by: bormanp <[email protected]>
* feat: add Compare function

* fix comment
* upd links to draft

* RFC 4122 -> 9562

* add extra comment

---------

Co-authored-by: bormanp <[email protected]>
* feat: add error types

* fix: broken backward compatibility
@tkarrass tkarrass changed the title Add custom node ids feat: add custom node ids Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.