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

How to choose id generation algorithm? #37

Closed
gcnyin opened this issue Jun 26, 2020 · 3 comments · Fixed by #40
Closed

How to choose id generation algorithm? #37

gcnyin opened this issue Jun 26, 2020 · 3 comments · Fixed by #40
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@gcnyin
Copy link

gcnyin commented Jun 26, 2020

I found it used uuid1 as default implementation.

UUID v1 is unique in theory, but still has potential problem. As we know UUID v1 is generated by using a combination the host computers MAC address and the current date and time. I am worried about node.js cluster. Does it safe on node.js cluster on a single machine?

And also, for some systems, they use their own id generator, I think it should have a way to pass user's own generator.

@puzpuzpuz puzpuzpuz added the enhancement New feature or request label Jul 4, 2020
@puzpuzpuz
Copy link
Owner

Yes, the library uses UUID V1 as the only supported id generator function. On the same machine, theoretically you can face duplicates by creating more than 2^14 UUIDs in less than 100ns. Also, UUID V1 uses the MAC address which may be a concern in rare cases.

In practice collisions are unlikely to happen, but I like the idea of adding support for custom id generator function. So, I'm marking this issue as an enhancement. Thanks for opening this issue. 👍

I should be able to address in later this month, but if you want to contribute, that would be awesome.

@gabriel-pinheiro
Copy link
Contributor

Hey @puzpuzpuz . I'd like to take this issue, may I get it assigned to me?

@puzpuzpuz
Copy link
Owner

@gabriel-pinheiro sure. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants