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 gen id within range of int53? #56

Open
shellohunter opened this issue Jun 24, 2024 · 1 comment
Open

how to gen id within range of int53? #56

shellohunter opened this issue Jun 24, 2024 · 1 comment

Comments

@shellohunter
Copy link

I'm having a trouble integrating sonyflake into my project. sonyflake only generates int64. unfortunately int64 is not officially supported by javascript or lua. there will be a precision lost. If I can restrict the output in the range of int53 (with the trailing 11 bits set to 0), then everything will be just fine.

I know there are some configs like BitLenSequence, BitLenTime, but I'm unable to alter them since they are defined as constants.
Is there anyway out?

@sallam-dev
Copy link

Why not treat them as strings in JS and Lua instead of losing the precision?

If they are generated in a Go server they can be serialized to a string for JS applications.

They can also be deserialized to uint64 on API requests

Is this your use-case?

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

No branches or pull requests

3 participants
@shellohunter @sallam-dev and others