- App-scoped typed Publish/Lookup with duplicate-provider errors - Set plugin IDs before Register so HasPlugin sees the full set - Greeter uses pact.OptionalMessage without importing optional
44 lines
922 B
Go
44 lines
922 B
Go
package optional
|
|
|
|
import (
|
|
"embed"
|
|
"io/fs"
|
|
|
|
"git.golem15.com/golem15/summercms/backpack"
|
|
"git.golem15.com/golem15/summercms/pact"
|
|
"git.golem15.com/golem15/summercms/party"
|
|
)
|
|
|
|
//go:embed config
|
|
var configFS embed.FS
|
|
|
|
// Plugin is the golem15.optional plugin. Greeter may use it without importing this package.
|
|
type Plugin struct{}
|
|
|
|
func (p *Plugin) ID() string { return "golem15.optional" }
|
|
func (p *Plugin) Requires() []string { return nil }
|
|
|
|
func (p *Plugin) Register(app *backpack.App) error {
|
|
if app == nil {
|
|
return nil
|
|
}
|
|
return app.Publish[pact.OptionalMessage](extra{})
|
|
}
|
|
|
|
func (p *Plugin) Boot(*backpack.App) error { return nil }
|
|
|
|
func (p *Plugin) ConfigFS() fs.FS { return configFS }
|
|
|
|
type extra struct{}
|
|
|
|
func (extra) Message() string { return "hello-from-optional" }
|
|
|
|
var (
|
|
_ pact.HasConfig = (*Plugin)(nil)
|
|
_ pact.OptionalMessage = extra{}
|
|
)
|
|
|
|
func init() {
|
|
party.Register(&Plugin{})
|
|
}
|