Skip to main content

Exactly-once effects on at-least-once delivery

Challenge on lesson: Checkpoint: Distributed Systems

CHALLENGE
Difficulty: advanced+25 XP

Implement process_stream(jobs, max_attempts=3) where jobs is a list of [job_id, payload, attempts] batches over time (concatenate them in order): - maintain done (dict job_id โ†’ 'done:' + job_id) and dead (list of [job_id, payload, attempts]) - a job already in done is skipped โ€” its effect happened once, redelivery is a no-op - a 'poison' payload increments its attempt counter each time it is seen; when attempts reach max_attempts it moves to dead (as [job_id, payload, max_attempts]) and is never processed again - any other payload is effected exactly once (added to done) the first time it is seen - return {'done': {...}, 'dead': [...]} Example: [[('j1','work',0)], [('j1','work',0), ('p','poison',0)], [('p','poison',1)], [('p','poison',2)]] with max_attempts=3 โ†’ j1 done once, p dead at attempts 3 (sightings 0,1,2 โ†’ attempts 1,2,3).

Back to lesson: Checkpoint: Distributed Systems