Repository navigation
Conversation
bgentry
force-pushed
the
bg/plugin-peer-work-hooks
branch
2 times, most recently
from
October 13, 2026 14:47
8734927 to
88e8ce3
Compare
bgentry
force-pushed
the
bg/plugin-peer-work-hooks
branch
from
October 13, 2026 14:49
88e8ce3 to
72ee6e9
Compare
brandur
approved these changes
Oct 13, 2026
An extension that claims and completes peers through `PeerAttempts` works those jobs itself, so River never runs the client's `Hook::work_begin` and `Hook::work_end` hooks for them. Per-job processing that lives in those hooks, such as decoding arguments that were transformed on insertion, is skipped for every peer. Add `PeerAttempts::work_begin` and `PeerAttempts::work_end`, which run the client's configured hooks for a given row exactly as the executor does for a job it works: in registration order, with the coordinator's work context, begin hooks mutating the row and stopping at the first error, and end hooks threading the result from one to the next. The begin helper returns the failing hook's error unchanged so the caller can fail that one peer with a `PeerOutcome` and keep working the rest. `PeerAttempts` is the natural home because it already resolves the coordinator's client and running attempt, and keeps a peer's whole lifecycle (claim, work hooks, completion) on one type. The end helper takes and returns the boxed error type `PeerOutcome` uses. A `WorkError` passed through a box is now unwrapped rather than wrapped a second time when a peer's outcome is recorded, so hooks and the error handler can downcast a peer's error to its original type, as they can for a worker's error. New peer-attempt scenarios on Postgres and SQLite cover hook order, argument changes seen by later hooks and by end hooks, a begin failure failing only its own peer, an end hook replacing a failure before the error handler runs, and rejection outside a running attempt.
bgentry
force-pushed
the
bg/plugin-peer-work-hooks
branch
from
October 13, 2026 23:41
72ee6e9 to
1d0186f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In River for Rust, when an extension claims and completes jobs itself through
PeerAttempts, River never runs the client'sHook::work_beginandHook::work_endhooks for them. Any per-job processing in those hooks is skipped for peers, including decoding arguments that were transformed when they were inserted.This adds
PeerAttempts::work_beginandPeerAttempts::work_endto the unstable extension module. They run the client's configured hooks for a given row the same way the executor does for a job it works: in registration order, with the coordinator's work context. Begin hooks can change the row and stop at the first error. End hooks pass the result from one to the next.work_beginreturns the failing hook's error unchanged, so the extension can fail that one peer and keep working the others.work_endtakes and returns the boxed error type thatPeerOutcomeuses. When a peer's outcome is recorded, a boxedWorkErroris now unwrapped instead of being wrapped again. That lets hooks and the error handler downcast a peer's error to its original type, as they already can for a worker's error.JavaScript needs no change.
PilotAttempts.claimalready applies the client's argument read transforms to the peers it returns.