Build and Extend It
Run the complete example:
cd examples/toy-job-runner
cargo test
cargo run
Read src/lib.rs in this order:
JobHandle<T, E>and itsIntoFutureimplementation;JobRunner::submitand the per-job oneshot pair;ErasedJoband why its output is();dispatchand itsJoinSetadmission condition;shutdownand the accepting/stopped state transitions;- the three invariant-focused tests.
Then implement these extensions one at a time:
try_submitreturningFullversusShuttingDownwithout awaiting.- A
Jobtrait adapter implemented in terms of the future API. - Caller-supplied job weights with a semaphore-based total budget.
- Explicit cancellation whose handle drop still remains inert.
- Multiple runner instances with different queue/concurrency policies.
- Metrics for queued, running, completed, failed, and abandoned results.
Only after that compare the toy with Apalis. The toy’s futures are arbitrary in-memory work; Apalis payloads cross durable backend and codec boundaries. That one requirement explains much of the production library’s additional generic and lifecycle machinery.