Let job args return plugins like they can for hooks/middleware - #1337
Open
brandur wants to merge 1 commit into
Open
Let job args return plugins like they can for hooks/middleware#1337brandur wants to merge 1 commit into
brandur wants to merge 1 commit into
Conversation
Here, implement a job args `jobArgsWithPlugins` interface that lets job args return a set of `Plugins`. This follows up the addition of plugins in #1284, and makes the functionality symmetrical to what's available with hooks/middleware. I would have done this before, but I forgot that you could do this until I was looking at docs today. As in #1284 for client config, `Hooks` and `Middleware` continue to be supported on job args and have not yet been deprecated. type EmailArgs struct { To string `json:"to"` } func (EmailArgs) Kind() string { return "email" } func (EmailArgs) Plugins() []rivertype.Plugin { return []rivertype.Plugin{ &EmailPlugin{}, } } type EmailPlugin struct { river.PluginDefaults } func (p *EmailPlugin) WorkBegin(ctx context.Context, job *rivertype.JobRow) error { return nil } I also had Codex look for opportunities for implementation clean up since all of this was feeling like a few too many LOCs. It was able to clean up ~85 LOCs net, with the main change being to get rid of `PluginLookupInterface` + `emptyPluginLookup`. This removes a layer of indirection, which is good, but also `emptyPluginLookup` had become less useful due to River installing default middleware (`ResumableMiddleware`) on all clients whether any has been specified by a client or not.
brandur
force-pushed
the
brandur-job-plugins
branch
from
July 30, 2026 19:20
56c927f to
3f6cc5d
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.
Here, implement a job args
jobArgsWithPluginsinterface that lets jobargs return a set of
Plugins. This follows up the addition of pluginsin #1284, and makes the functionality symmetrical to what's available
with hooks/middleware. I would have done this before, but I forgot that
you could do this until I was looking at docs today. As in #1284 for
client config,
HooksandMiddlewarecontinue to be supported on jobargs and have not yet been deprecated.
I also had Codex look for opportunities for implementation clean up
since all of this was feeling like a few too many LOCs. It was able to
clean up ~85 LOCs net, with the main change being to get rid of
PluginLookupInterface+emptyPluginLookup. This removes a layer ofindirection, which is good, but also
emptyPluginLookuphad become lessuseful due to River installing default middleware (
ResumableMiddleware)on all clients whether any has been specified by a client or not.