Skip to main content

Practice ยท 1 of 1

TaskFlow core: idempotent submits, budgeted retries

Implement TaskFlowCore (milestones 1+2 of the capstone): - submit(key, payload) โ†’ job id 'job-<n>' (n counts submissions); submitting the SAME key again returns the ORIGINAL job id without counting or queueing anything (the idempotency gate, covering pending, in-flight, succeeded, and dead jobs) - deliver() โ†’ list of [job_id, key, payload, attempts], moving pending jobs in-flight and re-delivering in-flight ones (lease expiry) - process(job_id, outcome) โ€” True records success; a string records a failure reason, increments attempts, and re-queues; at attempts >= 3 the job moves to the dead tier carrying the LAST reason and attempt count; unknown job ids are ignored - status(job_id) โ€” dict with 'status' one of 'pending'/'in_flight'/'succeeded'/'dead' (plus key/payload/attempts/reason as appropriate), or None for unknown ids - metrics property โ€” {'submitted', 'succeeded', 'failed', 'dead'} counts Delivered jobs whose outcome was already recorded must be skippable: a redelivered succeeded job neither re-executes nor corrupts counts.

Difficulty: advanced

Back to lesson: Practice: Milestone 1+2: The Core Loop