Repository navigation
Add NewV7WithTime, NewV8 and typed length errors - #1
Open
jai-deepsource wants to merge 1 commit into
Open
jai-deepsource wants to merge 1 commit into
jai-deepsource wants to merge 1 commit into
Conversation
- Add NewV7WithTime for backfilling records with an existing creation time, kept out of the NewV7 monotonic sequence - Add NewV8 and NewV8FromBytes for RFC 9562 custom UUIDs - Add UUID.Timestamp, IsNil, IsMax, AppendText and AppendBinary - Binary length errors now match ErrInvalidLength and Scan wraps parse errors with %w so errors.Is works through them - NullUUID text and binary decoding now round trip the invalid value - Fix data race in NewV6WithTime, which called getTime without holding timeMu - Make EnableRandPool and DisableRandPool safe to call concurrently - Move errors and rand pool code into errors.go and rand.go, share hex decoding between Parse, ParseBytes and Validate - Skip down and loopback interfaces when picking a node ID - Switch to go:build tags, set go 1.19 in go.mod, run vet, race and gofmt in CI - Move v7 tests into version7_test.go and add tests for the new behaviour
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
NewV7WithTimeand RFC 9562 version 8 UUIDs. Adds typed length errors that work witherrors.Is. Fixes two data races. Splitsuuid.gointo smaller files.Changes
New API
NewV7WithTime(t)builds a v7 UUID from an existing creation time, for example to backfill records. It stays out of theNewV7monotonic sequence.NewV8(data)andNewV8FromBytes(b)build custom UUIDs.UUID.Timestamp,IsNil,IsMax,AppendTextandAppendBinary.Errors
ErrInvalidLength.Scanwraps parse errors with%w.NullUUIDtext and binary decoding round trips the invalid value.Concurrency
NewV6WithTimenow holdstimeMuwhile it callsgetTime.EnableRandPoolandDisableRandPoolcan be called concurrently.Cleanup
errors.goand the rand pool moves torand.go.Parse,ParseBytesandValidateshare one hex decoder.go:build, andgo.modsets go 1.19.Testing
go test -race ./...version7_test.go. New tests cover v8,NewV7WithTime, theNullUUIDround trip, and theerrors.Isbehaviour.