Basic plugin system with centralized registry
This commit is contained in:
11
example/pluggable/myplugin/main.go
Normal file
11
example/pluggable/myplugin/main.go
Normal file
@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.com/wpetit/goweb/plugin"
|
||||
)
|
||||
|
||||
func RegisterPlugin(ctx context.Context) (plugin.Plugin, error) {
|
||||
return &MyPlugin{}, nil
|
||||
}
|
19
example/pluggable/myplugin/plugin.go
Normal file
19
example/pluggable/myplugin/plugin.go
Normal file
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import "log"
|
||||
|
||||
type MyPlugin struct{}
|
||||
|
||||
func (e *MyPlugin) PluginName() string {
|
||||
return "my.plugin"
|
||||
}
|
||||
|
||||
func (e *MyPlugin) PluginVersion() string {
|
||||
return "0.0.0"
|
||||
}
|
||||
|
||||
func (e *MyPlugin) HookInit() error {
|
||||
log.Println("MyPlugin initialized !")
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user