-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.go
More file actions
24 lines (20 loc) · 774 Bytes
/
plugin.go
File metadata and controls
24 lines (20 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package plugin
// Plugin is the interface every backend plugin must implement.
type Plugin interface {
// Init is called once when the plugin is loaded. Register route handlers
// and event subscriptions on the provided Context.
Init(ctx *Context) error
// Shutdown is called before the plugin module is unloaded. Use it to
// flush buffers or close any open resources.
Shutdown()
}
// globalDispatcher is the singleton created by [Run].
//nolint:unused // used by wasm_exports.go in WASM builds
var globalDispatcher *dispatcher
// Run wires the plugin into the WASM host function contract. Call it from
// main() with the concrete Plugin implementation:
//
// func main() { plugin.Run(&myPlugin{}) }
func Run(p Plugin) {
globalDispatcher = newDispatcher(p)
}