Open webard opened 8 months ago
Hello,
Thank you for using this library. In the current implementation, the values of WORKER_ID and DATACENTER_ID are not used in generating Shortflake IDs, and IDs are primarily generated based on time and sequence ID.
Generating shorter IDs can be convenient, especially when dealing with long integers in JavaScript clients. However, as a trade-off, the number of unique IDs that can be generated per millisecond is reduced, and the ability to distribute ID generation across multiple workers and data centers is lost.
If your application requires the use of WORKER_ID and DATACENTER_ID in a more distributed environment or needs to increase the uniqueness of the IDs, please consider using the toSnowflakeId method instead and managing the IDs as strings.
Please let us know if you have any other questions or if there's anything else we can help with.
What do you think about this implementation: https://samifayoumi.ca/blog/001_53bit-snowflakeid ? It is possible to cut-off sequence id to introduce at least worker id
I found this implementation very interesting. Introducing the worker ID by truncating the sequence ID, as proposed, seems like a good idea to enhance the scalability of the system.
I would love to incorporate this mechanism into this library, but currently, I'm having difficulty finding enough time. If you're in a hurry, I would appreciate it if you could submit a PR.
I can manage this, but how name this implementation? I wouldn't change the current implementation of Shortflake, but introduce something like TaggedShortflake, ScalableShortflake, ShortflakeV2, Snowflake53? Do you have an idea for the best fit?
I couldn't think of a good name. Instead, we could keep the name as it is and introduce the new implementation as a major update, marking it as version 3.0.
Hello,
I use shortflakes in my app due to compatibility with laravel nova and some other apps (it is just simpler in Javascript API clients) and I wonder that Shortflakes use WORKER_ID and DATACENTER_ID from config?
In this code: https://github.com/kra8/laravel-snowflake/blob/0f517d4efaf9ee5b93ae8dfa1350bc5ca32fd25b/src/Snowflake.php#L132-L135 i do not see logic that is present in
toSnowflakeId
method.So how Shortflake works for now, what are benefits from using shortflakes?
Best