Synchronizing System Clock

Id Generator depends strongly on the system’s clock. Although the generator will continue to produce unique ids when clock goes back, it’s better to synchronize your server’s time with NTP in a mode which doesn't move the clock backwards.

If your can’t control time synchronization and your clock may move backwards it is suggested to instantiate your id generators providing the last id generated for each node.

// Constructs an Id generator for node 0 which will 
// generate ids that come after the lastId
val generator = Generator(0L, lastId)
Fork me on GitHub