|
1 |
| -// Copyright (c) 2021 CoderMe.com |
| 1 | +// Copyright (c) 2022 CoderMe.com |
2 | 2 | // Permission to use, copy, modify, and distribute this software for any
|
3 | 3 | // purpose with or without fee is hereby granted, provided that the above
|
4 | 4 | // copyright notice and this permission notice appear in all copies.
|
|
19 | 19 |
|
20 | 20 | Generating IDs:
|
21 | 21 |
|
22 |
| - IDs generated are partially time-sortable, guranteed to be unique only if the program is running by one |
| 22 | + IDs generated are partially time-sortable, guaranteed to be unique only if the program is running by one |
23 | 23 | process and on a single server. On cluster of servers or multiple processes per server, further configuration
|
24 | 24 | is needed.
|
25 | 25 |
|
26 |
| - Int64(serverID, processID, Config) and Uint64(serverID, processID, config) can be used to generate IDS with |
| 26 | + Uint32(serverID, processID, Config) and Uint64(serverID, processID, config) can be used to generate IDS with |
27 | 27 | fixed serverID and processID on simple setups.
|
28 | 28 |
|
29 | 29 | For more two servers or more, there are os nviroment depenedant which lookup up serverID is environment
|
30 |
| - SERVER_ID and processID in enviroment variable PROCESS_ID |
| 30 | + SERVER_ID and processID in environment variable PROCESS_ID |
31 | 31 |
|
32 | 32 |
|
33 | 33 | Arguments:
|
|
42 | 42 | The default configration supports upto 1024 servers and upto 32 processes per each one.
|
43 | 43 |
|
44 | 44 | To support more than 1024 servers, or more than 32 processes, consider customizing processBits and serverBits
|
45 |
| - by using NewInt64Config() and NewUint64Config() for Int64(), EnvInt64() and its uint equivelent Uint64() |
| 45 | + by using NewUint32Config() and NewUint64Config() for Uint32(), EnvUint32() and its uint64 equivalent Uint64() |
46 | 46 | EnvUint64() functions respectively.
|
47 | 47 |
|
48 | 48 | Configurations are thread-safe and should be reused across multiple goroutines.
|
|
56 | 56 |
|
57 | 57 |
|
58 | 58 | * One server with multiple processes:
|
59 |
| - = Consider using processes manager like systemd, in order to decrease the os dynamic proces sid |
| 59 | + = Consider using processes manager like systemd, in order to decrease the os dynamic process sid |
60 | 60 | aka (pid) gap, large gaps between pid increase the likelihood of exhasting processbits.
|
61 | 61 |
|
62 | 62 | = A better solution would be use static processID as environment variable available for a single
|
63 |
| - process each. Then use EnvInt64 and EnvUint64. |
| 63 | + process each. Then use EnvUint32 and EnvUint64. |
64 | 64 |
|
65 | 65 |
|
66 | 66 | * Multiple servers with multiple processe:
|
|
70 | 70 |
|
71 | 71 | */
|
72 | 72 | package oneid
|
73 |
| - |
0 commit comments