The README states this limitation where somebody can find it, and it is the most
interesting open problem in the library:
with the facade, timers live in the process that received the message. If that process
dies with a turn buffered, the turn waits for the next message instead of firing on
time.
The state is safe: it is in the store, buffer and firstBufferedAt included. What is
lost is the setTimeout that was going to close it, so the answer arrives late, whenever
the person happens to say something else.
What a solution has to respect
- The core stays pure.
src/core returns schedule as data and creates no timers.
Whatever recovers a turn belongs in the runtime or in a store, never in the reducer.
- No runtime dependencies.
- More than one process. Two instances must not both emit the same conversation's
turn, so whatever recovers it takes the same per-conversation lock everything else
takes.
Directions
- A sweep on an interval, asking the store for conversations whose deadline has passed.
This needs the store to answer a question it cannot answer today: Store has no way to
list anything. That is the design decision to make first, and it is not a small one.
- Leave it to the deployment and document the shape.
examples/serverless.ts already
delegates the tick to an external scheduler, and the answer for the facade may be to
say so louder rather than to build a sweeper.
Comments are welcome before code. This one is worth agreeing on before anybody writes
it.
The README states this limitation where somebody can find it, and it is the most
interesting open problem in the library:
The state is safe: it is in the store, buffer and
firstBufferedAtincluded. What islost is the
setTimeoutthat was going to close it, so the answer arrives late, wheneverthe person happens to say something else.
What a solution has to respect
src/corereturnsscheduleas data and creates no timers.Whatever recovers a turn belongs in the runtime or in a store, never in the reducer.
turn, so whatever recovers it takes the same per-conversation lock everything else
takes.
Directions
This needs the store to answer a question it cannot answer today:
Storehas no way tolist anything. That is the design decision to make first, and it is not a small one.
examples/serverless.tsalreadydelegates the tick to an external scheduler, and the answer for the facade may be to
say so louder rather than to build a sweeper.
Comments are welcome before code. This one is worth agreeing on before anybody writes
it.