-
-
Notifications
You must be signed in to change notification settings - Fork 917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add plugin system (fixes #3562) #5498
base: main
Are you sure you want to change the base?
Conversation
a21ede2
to
2216744
Compare
This and the RFC are ready to merge, so that devs can already start to work on plugins. |
for p in plugins.0 { | ||
// TODO: add helper method (requires PoolPlugin to be public) | ||
// https://github.com/extism/extism/pull/696/files#r2003467812 | ||
let p = p | ||
.plugin_pool | ||
.get(&(), GET_PLUGIN_TIMEOUT)? | ||
.ok_or(anyhow!("plugin timeout"))?; | ||
if p.plugin().function_exists(name) { | ||
let params: Json<T> = data.clone().into(); | ||
p.call::<Json<T>, ()>(name, params) | ||
.map_err(|e| LemmyErrorType::PluginError(e.to_string()))?; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you externalize this to a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately not, because the PoolPlugin
type is not public (thats what the todo is for, I left a review comment in the upstream PR so it will hopefully get fixed later). The plugin call can also not be externalized, because the pre hook needs to return data but the post hook not.
crates/api_common/src/plugins.rs
Outdated
*data = res; | ||
let mut plugins = LemmyPlugins::init(); | ||
let mut res: Json<T> = data.clone().into(); | ||
for p in &mut plugins.0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then no need to copy paste.
See LemmyNet/rfcs#8 and #4695. Depends on a work in progress feature of Extism to add plugin pools for concurrency (extism/extism#696).
Todo:
/api/v4/site