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

fix!: refactor v1 internal state and options logic #780

Merged
merged 6 commits into from
Jul 20, 2024
Merged

fix!: refactor v1 internal state and options logic #780

merged 6 commits into from
Jul 20, 2024

Conversation

broofa
Copy link
Member

@broofa broofa commented Jul 18, 2024

Refactoring v1 code to align with the changes in #779.

Changes of note:

  • Decouple behavior of v1()-with-options from v1()-without-options
  • Encapsulate internal state handling and refactor to be more idiomatic
  • Removed the throw that limits UUID-generation rate, and instead reset the node.
  • Update RFC references in comments to link to RFC9562
  • Remove v1-rng.test and v1-random.test (no longer needed)

Note: While working on this new logic I realized the semantics of the clockseq field were unnecessarily complicated. (e.g. incrementing it on clock regression rather than randomizing). So (for UUIDs generated using internal state) the clockseq and node fields are treated as a single rand field (v7). They are initialized and updated at the same time - namely if there's a clock regression, or the generation rate exceeds the clock resolution. This significantly simplifies the state transition logic.

@broofa broofa merged commit 031b3d3 into main Jul 20, 2024
12 checks passed
@broofa broofa deleted the v1_options branch July 20, 2024 13:15
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.

1 participant