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: generate uuid V7 base on provided time #179

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

Conversation

snaffi
Copy link

@snaffi snaffi commented Dec 17, 2024

No description provided.

@snaffi snaffi requested a review from a team as a code owner December 17, 2024 10:19
Copy link

google-cla bot commented Dec 17, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@snaffi snaffi changed the title generate uuid V7 base on provided time feat: generate uuid V7 base on provided time Dec 17, 2024
@@ -85,11 +99,11 @@ const nanoPerMilli = 1000000
// getV7Time returns the time in milliseconds and nanoseconds / 256.
// The returned (milli << 12 + seq) is guaranteed to be greater than
// (milli << 12 + seq) returned by any previous call to getV7Time.
func getV7Time() (milli, seq int64) {
func getV7Time(timeFunc func() time.Time) (milli, seq int64) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the behavior later in this function with lastV7time I don't think we want that when using a custom timestamp. Basically if you pass in a future time, then a past time, the past time will get reset to be in the future. I opened #182 that doesn't have this issue.

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.

2 participants