Documentation ¶
Overview ¶
Currently this package only contains the definitions for various plugin types. It is planned to contain a plugin manager interface and an implementation of one to make simple "startup scripts" listing plugins.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIPlugin ¶
type APIPlugin interface { Plugin // A router mounted on /. Generally, keep API extensions inside of // `/api/`; this interface gives / for well-known URIs, etc. Route(chi.Router) }
A plugin with an API router.
type Manager ¶
type Manager interface { // On error, returns the index of the plugin erroring and the error // received, or “(-1, nil)“ if all plugins initialized successfully. AddPlugins(...Plugin) (int, error) GetPluginMap() map[string]Plugin // Finishishes initializing each plugin, specifically by passing the // plugin map to CrossPlugins. Finalize() // Starts listening. If the Server pointer is nil, Listen will use the // implementation default. Implementors should not modify a passed // Server except its Handler. Listen(*http.Server) // Shuts down the “http.Server“ in Listen() and calls Destroy() on // each plugin. Returns any error in shutting down, for instance from // “http.Server.Shutdown()“. Shutdown() error }
func GetDefaultManager ¶
Returns a Manager using “config/hub.yml“ to set up.
type Plugin ¶
type Plugin interface { Init(*log.Logger, PluginParams) error // Returns the D-Bus or Java–style name for the plugin. Must not rely // on an earlier Init() call. DBusName() string // Function to close connections, end requests, etc. Destroy() }
A plugin.
There is an example plugin in the package codeberg.org/libreedu/hub/plugins/example which simply registers the endpoint `/api/example-plugin` and returns the string "Hello, world!"
Plugins should use package-scope variables, if they must work with `-buildmode plugin`, because exported shared object types cannot maintain state.
type PluginParams ¶
type PluginParams struct { // A struct containing a bun DB, generally Postgres or another system // supporting PL/pgSQL. If you prefer, you can access a `*sql.DB` at // `plugin.DB.DB.DB`. // // Please be mindful of other plugins and contain your plugin's data // in its own Postgres schema. DB *DB // A Viper config object pointing to your plugin configuration. Ensure // that you call ReadInConfig(). Config *viper.Viper }
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
The `models` module provides core database types like User.
|
The `models` module provides core database types like User. |
plugins
|
|
example
Use codeberg.org/libreedu/hub/plugins/example/import in launch script
|
Use codeberg.org/libreedu/hub/plugins/example/import in launch script |