HardPro challengePythonJavaScriptTypeScript

Transactional Outbox Replay

Node.jsDistributedReliability

Process an outbox: events are [id, payload]. The processor may fail
(returns false). On failure, retry up to maxRetries times. Each event must
be delivered exactly once in id order. Skip events permanently failed.

solve(events, attemptsByEventId, maxRetries) where attemptsByEventId
maps event id → number of attempts before success (or > maxRetries to fail).

Returns { delivered: [id, ...], dropped: [id, ...] }.

Sample tests

Test #1All succeed first try
Input: [[[1,"a"],[2,"b"]],{"1":1,"2":1},3]
Output: {"dropped":[],"delivered":[1,2]}
Test #2Drops after maxRetries
Input: [[[1,"a"]],{"1":5},3]
Output: {"dropped":[1],"delivered":[]}
Test #3Mixed
Input: [[[1,"a"],[2,"b"]],{"1":2,"2":4},3]
Output: {"dropped":[2],"delivered":[1]}
Test #4Just within retries
Input: [[[1,"a"]],{"1":3},3]
Output: {"dropped":[],"delivered":[1]}
Test #5Empty outbox
Input: [[],{},3]
Output: {"dropped":[],"delivered":[]}