puzpuzpuz/cls-rtracer

How to choose id generation algorithm?

gcnyin opened this issue · 3 comments

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.

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.

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