When testing with a large amount of concurrent requests for my previous PR #45 I noticed id collisions were very frequent.
I believe this was happening because if 2 ids are generated at the same time they can get the same seed resulting in their IDs being the same. This PR changes the id generation to just set the seed once and use our own random number source instead of the library default.
We need a Mutex here because random sources are not concurrency safe, Internally rand.Read also uses a Mutex.
Another solution could be to just not set the seed every time we generate an ID.
When testing with a large amount of concurrent requests for my previous PR #45 I noticed id collisions were very frequent. I believe this was happening because if 2 ids are generated at the same time they can get the same seed resulting in their IDs being the same. This PR changes the id generation to just set the seed once and use our own random number source instead of the library default.
We need a Mutex here because random sources are not concurrency safe, Internally
rand.Read
also uses a Mutex.Another solution could be to just not set the seed every time we generate an ID.