MatrixAI / js-id

ID generation for JavaScript & TypeScript Applications
https://polykey.com
Apache License 2.0
10 stars 1 forks source link

IdSortable should throw an exception it exhausts its seq bitspace #16

Open CMCDragonkai opened 1 year ago

CMCDragonkai commented 1 year ago

Specification

If the seq bitspace gets exhausted either within the 1 millisecond interval, or waiting for the OS clock to catch up to the last ID, the IdSortable should throw an exception. Any further generated IDs would no longer be valid, and therefore would violate the monotonic constraint of IdSortable.

Additional Context

Tasks

  1. Check if the seq bitspace is exhausted when generating an id
  2. Throw an exception like ErrorIdSortableSequenceRollover or ErrorIdSortableCounterExhausted...
  3. Tests for if one generates too many ids while mocking a static time.
  4. Tests for if the last ID is too far in the past.
CMCDragonkai commented 1 year ago

I think right now it just rolls over. You'd need to generate over 4K IDs within 1ms for this to be a problem.