Closed tausif-deepsource closed 3 years ago
There's nothing wrong with 59-bit values. The final representation depends on the formatting, but the value will not exceed the set (39 + 16 + 8) 63 bits.
A sample equivalent generation from golang gives:
362637573840961538 10100001000010110001111001110111011000000000000000000000010
which is also 59-bits. The code used:
func main() {
var st sonyflake.Settings
sf := sonyflake.NewSonyflake(st)
id, err := sf.NextID()
fmt.Printf("%d \t %b\n", id, id)
}
Got it thanks.
Just one follow up question what is the correct way to generate ids in a production setting i mean should i instantiate it once globally and generate ids from the instance? or is there a better optimal way kindly suggest.
Got it thanks.
Just one follow up question what is the correct way to generate ids in a production setting i mean should i instantiate it once globally and generate ids from the instance? or is there a better optimal way kindly suggest.
The library uses a thread lock, so a single instance should work fine. Try and please ping if you face any issues.
Thanks for being responsive i will be using this in production so will reach out if i face any issues :)
hey, i am getting 59 bit values what am i missing or not doing correctly?