consistent
consistent copied to clipboard
Use a delimiter between host name and it's replication index
fmt.Sprintf("%s%d", host, i)
What if host names will be: host1, host2, ... host21, host22. Current mechanism of replications naming will produce a lot of collisions. Some sort of delimiter is required:
const delimiter = "æ" // some rare utf-8 symbol
...
fmt.Sprintf("%s%s%d", host, delimiter, i)
For example unicode 'SYMBOL FOR UNIT SEPARATOR' may be used: https://www.fileformat.info/info/unicode/char/241f/index.htm
Why would it produce collisions?
Oh, sorry. It will not produce collisions. I reproduce this because i tune replicationFactor in my copy of code.
If replicationFactor will be greater than 10 it may produce collisions:
- "host1" + "10" = "host110"
- "host11" + "0" = "host110"
But maybe a delimiter is still not a bad idea. Because it will help to avoid collisions that i receive when i try to tune this library.