f4b6a3 / tsid-creator

A Java library for generating Time-Sorted Unique Identifiers (TSID).
MIT License
475 stars 50 forks source link

Question: What precautions should be taken if it is necessary to change the TsidFactory later? #34

Closed marlonpatrick closed 2 months ago

marlonpatrick commented 2 months ago

For example, if I want change:

FROM: TsidCreator.getTsid256().toLong()

TO: TsidFactory.newInstance1024(NODE_ID_CALCULATED_BY_IP).create().toLong()

fabiolimace commented 2 months ago

I'm not sure. But as long as the epoch stays the same, say 1/1/2020, and considering that the clock doesn't (normally) go backwards, there shouldn't be any problems related to time. The reason for this is that the time component has a fixed number of bits.

I think the question is how the NODE_ID_CALCULATED_BY_IP is calculated and distributed to the TSID generators. You have to be sure that each NODE_ID_CALCULATED_BY_IP is associated to only one TSIDs generator. TSID generators rely on this "coordination" of node IDs.