| 1 | // Package work provides durable, fenced work intents backed by a storage.Store. |
| 2 | // |
| 3 | // Queue.Enqueue is idempotent by intent ID. Claim selects the oldest due |
| 4 | // pending intent, or a running intent whose lease expired, and assigns a |
| 5 | // random claim token. Renew, Complete, Retry and CancelClaim update an intent |
| 6 | // only while that token owns the claim, fencing updates from earlier attempts. |
| 7 | // |
| 8 | // Worker invokes the handler for a claim while renewing its lease. A nil or |
| 9 | // missing handler is an ordinary failure and is retried. Handler errors are |
| 10 | // retried with deterministic jittered exponential backoff; Stop marks the |
| 11 | // intent cancelled and records the underlying error. If lease renewal fails, |
| 12 | // the handler context is cancelled and its result is discarded as fenced. |
| 13 | // RunPool starts the requested number of workers, defaults to four, and stops |
| 14 | // the pool when its context is cancelled or a queue operation fails. |
| 15 | package work |