EventStore - last-event-id should always increment
Opened this issue · 0 comments
In order to maintain consistency when multiple connections are open for a single UUID, the system should not remove old events, trying to guess when a browser is trying to start a new session.
Each time a connection is made, while assigning a UUID to the connection, the EventStore needs a method to retrieve the MAX(last-event-id) for that UUID, and relay this number to the browser.
In order to help EventStore clean itself over time: set a timer event, when a new connection is established, to delete events more than 24 hrs old (or something like this). Also this timer event could ensure clean initialization of a connection by: (a) send all events in queue newer than 'last-event-id', and (b) flip a bit to say to server "we're caught up now. Please relay all subsequent events / messages directly to the browser.
In other words, for new connections, in order to prevent race conditions, we initialize in 2 phases: (1) we're connected, but until we've got an established connection with client please continue to queue messages, (2) we've now established a connection with the browser, please forward all queued messages, and flag this connection so we know we're safe to relay future messages directly to the browser.
** As a consequence we probably should make last-event-id in EventStore a BigInt.