alpha
Login
or
Join now
zzstoatzz.io
/
docket
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
zig port of github.com/chrisguidry/docket
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
docket
/
examples
/
at
main
1 folder
zzstoatzz
Worker: Io.Cancelable shutdown via io.async + future.cancel
2mo ago
8eea1c1d
perpetual
Worker: Io.Cancelable shutdown via io.async + future.cancel Replaces the atomic-stop-flag pattern with proper cancellation: - `Worker.runForever` is now a normal function that loops calling `tick()`. when a `tick()` returns `error.Canceled`, the loop exits cleanly. all other errors are logged-and-continued. - `tick()` propagates `error.Canceled` through every backend call site (promoteDueTasks / consumeStream / handleMessage) by switching on the catch and re-throwing Canceled vs. swallowing other errors. - `handleMessage` handles mid-task cancellation: a task body whose Io op returned Canceled propagates up; the worker still calls `ackMessage(..., "failed")` (the "next cancelation point" rule says ack runs normally), then re-throws Canceled so `runForever` exits. - Removed `Worker.stop()` and the `stopping: std.atomic.Value(bool)` field. Callers use `io.async(Worker.runForever, .{&w})` and `future.cancel(io)` to drive lifecycle. Memory backend's `consumeStream` previously ignored `block_ms` and busy-looped when empty. It now sleeps the configured interval via `std.Io.sleep`, which is both a cancellation point AND CPU-friendly. Real redis already blocked via XREADGROUP, so this brings the two backends into shape parity. Example updated: spawns `Worker.runForever` via `io.async`, sleeps 10s, calls `future.cancel`. End-to-end runs at ~10.2s wall clock on both backends with five perpetual ticks observed and clean exit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2 months ago