Repository navigation
[rust] complete extension hooks - #1501
Merged
Merged
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
bgentry
force-pushed
the
bg/plugin-peer-work-hooks
branch
from
October 13, 2026 23:41
72ee6e9 to
1d0186f
Compare
bgentry
force-pushed
the
bg/plugin-peer-work-hooks
branch
from
October 25, 2026 02:55
1d0186f to
8e1393b
Compare
bgentry
force-pushed
the
bg/plugin-peer-work-hooks
branch
from
October 25, 2026 03:08
8e1393b to
7f845cc
Compare
An extension that coordinates peer jobs works each peer itself, so the client's work hooks never run for peers. Add `PeerAttempts::work_begin` and `work_end`. They run the hooks in registration order and stop at the first failing begin hook, as the executor does. Keep the original error through hooks and outcomes. A boxed `WorkError` is reused instead of wrapped again, so hooks and the error handler can downcast the worker's error. A `JobCancelError` in a peer's error now cancels the peer, as it cancels a job a worker returns it from. Insertion extensions need resolved options in insert hooks and must see unique duplicates after persistence. Expose resolved options through the internal option trait. Pass every returned row to `after_jobs_inserted` in input order, with its requested metadata and a flag that marks existing duplicates. Add `ProducerClaimNext::claim_at_most`, so a producer session can claim fewer jobs than River's limit. The limit caps the requested maximum. A zero maximum runs no query. The continuation is consumed either way.
bgentry
force-pushed
the
bg/plugin-peer-work-hooks
branch
from
October 25, 2026 18:25
7f845cc to
0f7edd7
Compare
bgentry
marked this pull request as ready for review
October 25, 2026 18:30
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.
An extension that coordinates peer jobs works each peer itself, so the client's work hooks never run for peers. That includes hooks that decode job arguments. Insertion extensions also need resolved options in insert hooks, and they need to see unique duplicates after an insertion returns an existing row.
This adds
PeerAttempts::work_beginandwork_endto the unstable extension module. They run the client's hooks in registration order and stop at the first failing begin hook, as the executor does. Errors keep their original type through hooks and outcomes, so hooks and the error handler can downcast them. AJobCancelErrorin a peer's error cancels the peer, as it does for a job whose worker returns it. The executor's own begin-hook errors also skip the extra wrapper now.The internal option trait now exposes resolved insertion options. After persistence,
after_jobs_insertedgets every returned row in input order, including unique duplicates. Each row comes with its requested metadata and a flag that marks an existing duplicate. An extension can then base its bookkeeping on the stored row or on the request, within the same transaction.ProducerClaimNext::claim_at_mostlets a producer session claim fewer jobs than River's limit. The limit caps the requested maximum, a zero maximum runs no query, and the continuation is consumed either way.JavaScript already applies argument read transforms when it claims peers, so it needs no peer-hook change.