-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Plugin Mechanism #20126
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
Comments
I think https://github.com/hashicorp/go-plugin should also be taking in consideration, afaik the "normal" plugin system has a lot of shortcomings (eg crashing the whole process because of issues with the plugin), that the Hashicorp one does not suffer from. See also: |
Yeah, I've also seen their implementation when looking for a plugin system. Regarding the unexpected crashes: I intended to call every plugin by using something like func PluginCall(function func(plugin *Plugin)err) {
for _, plugin := range plugins {
executePluginCall(plugin)
}
}
func executePluginCall(plugin *Plugin, function func(plugin *Plugin)err) {
defer func(){
if err := recover(); err != nil { // Error handling
}
}()
function(plugin)
} and thus mitigating the potential for those errors. So, the question is now, should we use the RPC version which might offer a few benefits and higher latency, or do we stay with the Go native approach that we can completely customize to our liking? |
Do you want to compile/execute Go code on-the-fly? |
Not really, but we certainly need to handle the custom routes which can best be achieved dynamically, and making this interface-based might be possible, but (a little bit) more work. |
Wish you many luck with this advanced logic. |
I prefer the plugin system based on javascript or nodejs because that will allow it include frontend code. Possbile library be used. https://github.com/dop251/goja, there is also a plugin support nodejs . |
Interesting how many different views there are regarding this feature. |
Use javascript based plugin system, we can implement a plugin market and one click installation. That's impossible for Go based plugin system. |
The problem I can see is: We do not even have the same definition of what we want in the end: |
I don't think so. I think I'm also talking about per-instance plugin. If I made you confusing, I'm sorry. |
-1 for the go |
I think we can begin from a theme-kind plugin, which is simple and useful. A plugin could be a zip/tar file with a |
I do not think the Go's Most large Go projects uses gPRC for inter-process commutation, including plugins, but it's also heavy. |
Ok, seems as if the I'm still not a fan of a purely frontend-based plugin mechanism as that will have many shortcomings of its own, and I don't know if
should be the deciding factor for how to implement the plugin system... So, as I can see that now, the two possible options are
|
Isn't this library lunny suggested meant for a backend-based plugin mechanism? But instead of writing go you can write js? Or would that be to difficult to build a bridge between the Gitea go code and js code? |
Yes, it could expose structs, methods to frontend. i.e. If we expose getdb method, then we can operate database with javascript. |
I think the best way to go would be using grpc so that plugins could be implemented using any language. Plugin could return asset files on init (JavaScript etc) that would need to be injected/used in specific places |
I would also like to throw yaegi into the mix. |
Honestly, I would like to see the native go plugin implementation. But since thats off the table for now, I would rather go with the gRPC approach, since its more open (i.e. you can choose more languages) and imo more secure then javascript. The problems I see with js plugins is, that it lead to a huge security risk, since js can be so minified or encrypted that you not even need any letters (only parentheses) to write correct js. We then would need an very strict system so no js can accidentally just execute "DROP ALL TABLES;" (or similar) on startup. Also an interpreter (of any kind) in gitea would bring back the risk of one plugin crashing the whole instance, or to eat up so much performance that gitea stops responding (i.e. a infinite loop in a script somewhere). To mitigate this we then would need to sandbox the plugins into own processes, which would nearly the same as the gRPC approach but with less freedom. |
To be fair, you can also |
Then you have to think twice about an official plug-in market like lunny suggested. Official also indicates that they are save for usage and have no malicious intentions. An easy one click install could potentially break servers from not experienced users who don't understand what the plugin is doing and just pressing install. To prevent this, this would at least requires some reviewing and analysis of newly published plugins, which is time expensive. |
We could probably get some ideas on how mattermost have implemented their plugin system. |
For posterity: |
Another inspiration could be woodpecker proposal around extensions woodpecker-ci/woodpecker#915 |
Since nobody has mentioned it yet, projects like Adobe Lightroom, MPV, or Wireshark use Lua for this. You'd read and run Lua files from a directory where they would register events with callbacks or maybe return properties and functions. It's very light. simple, and fast but would make it very easy to make plugins and shouldn't be any harder to implement Made up possible example: -- Greet users on their first repo
gitea.on("newRepo", function(repo)
if #repo.owner.repos == 1 then
local msg = ("Welcome to our Gitea, %s!"):format(repo.owner.name)
repo.owner:sendNotifacation(msg)
end
end)
|
The Lua integration could be plugin too which forwards callbacks to Lua. |
Are there any updates on this one? ^^ |
For most backend tasks, Gitea Actions can be considered as somewhat plugins. |
Yeah for my usecase the webhooks are sufficient. I will just have to host another small webserver alongside Gitea. |
Then there are 4 point of views could be considered for plugins
and I will add the 5th
|
Looks like Typescript 7 will be migrated to Go. So that maybe we can use typescript as the plugin language. https://github.com/microsoft/typescript-go |
To be frank: For the "plugin" proposal, I do not see anyone is really working on it, or whether it is feasible at current stage (my answer is "no": either gPRC or js/wasm/lua would involves a lot of work to design the structs and interfaces, no manpower). Mission Impossible So I would suggest to mark the proposal as "close as not planned" since it doesn't seem able to get real progress (reopen at any time when there is a feasible design and manpower) For some existing requirements:
|
Quote above: So I would suggest to mark the proposal as "close as not planned" since it doesn't seem able to get real progress (reopen at any time when there is a feasible design and manpower) Golang eco-system is naturely not easy with plugins .... unfortunately. |
Maybe we can learn from git's plugin model, where commands that start with git- can be called freely by git, e.g. I have a git-bug plugin, and I can call my git-bug plugin by calling git bug. |
most top named Go/C/C++ projects support plugins including
there were many success stories and a cost effective announce using plugins opening the way to be integrated into other projects |
These examples you shown, are either desktop/traffic-server or C++ applications (Golang plugin doesn't work on Windows, but Gitea still needs to support), or the plugin doesn't need to heavily depend on the host application (traffic server: CoreDNS, Traefik). And either they have a large company & team, or a lot of active contributors to maintain. For Gitea's plugin: Gitea itself is a heavy web application (but not a traffic server), there are more business logic than others, the proposed "Plugin Lifecycle" is already more complex than the traffic server examples. And Gitea community is not that large as others (that's what I meant "my answer is no: either gPRC or js/wasm/lua would involves a lot of work to design the structs and interfaces, no manpower").
Actually it doesn't need a general plugin system, but you see that the webhook related PRs are still stale for long time (WIP: Custom Webhooks #19307). As simple as this one doesn't get success, how would a general plugin proposal succeed? I don't want to disappoint anyone, but I think we need to face reality. And see my comment above: reopen at any time when there is a feasible design and manpower |
Let's keep it open and don't disappoint anyone. Let's hope there would be some real progresses. |
A successful case of a go project: github cli, But this plugin mode only supports command line calls |
You need to find some "rich web application" to learn. |
I'm mainly a biology teacher and server admin, while I'm tring to learn Go I go slowly so my kwnolage is under just entry level or below ( gpt aided ), so I understand your point here, unfortunatly for now I can only help with ideas but we cant stop building next roadmap steps that it's just somehow far ( you may consider good suggestion for juat undetermined version )
you are right, I previously raised an issue here to enhance Frontend ( #31125 ) and separate it from backend so the backend just work independantly and could be integrated in any frontend - this may make the application focus more on functionality especially if PWA / SPA is considered for frontend as it will reduce SSR ( server side rendering ) and minimize validation to AuthN, AuthZ
yes but may introduce many panels to go for git workflow based deployments ( https://chatgpt.com/share/67f13ee5-3334-8005-82e8-7d087c1cb51b ) integrating gitea and making more developer wanting to contribute and develop more ( separate plugins )
you are thinking well, |
What should it be?
Architecture
Plugins are called using(see discussion below, was generally disliked)Go
splugin
package.go-plugin
Communication: Gitea ➡️ plugin ➡️ Gitea
modules/
:map[string]?
, where possible to avoid breaking changesCommunication: plugin ➡️ Gitea ➡️ plugin
Plugin Lifecycle (What the plugins can set/ "use")
Application is completely initialized and running
- HookOR
/AND
relations (depending on the chosen algorithm)?What data is needed by every/ some plugin(s)?
io.gitea.example_plugin
)Example Plugin V1
)Why this long text rambling?
The text was updated successfully, but these errors were encountered: