New capability interfaces: - menus.Menus: menu/nav access (GetMenuByName, GetMenuItems) - subscriptions.Subscriptions: tier/plan access (GetUserTierLevel, GetTierBySlug, ListActivePlans) - auth.PublicUsers: public user profiles (GetByUsername, GetByID) - plugin.PluginBridge: inter-plugin service registry with typed GetServiceAs[T] helper All added to ServiceDeps for plugin consumption. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
23 lines
654 B
Go
23 lines
654 B
Go
package plugin
|
|
|
|
// PluginBridge allows plugins to share services with each other.
|
|
// Plugins register named services during startup; other plugins look them up at runtime.
|
|
type PluginBridge interface {
|
|
RegisterService(pluginName, serviceName string, service any)
|
|
GetService(pluginName, serviceName string) any
|
|
}
|
|
|
|
// GetServiceAs retrieves a typed service from the bridge.
|
|
func GetServiceAs[T any](bridge PluginBridge, pluginName, serviceName string) (T, bool) {
|
|
var zero T
|
|
if bridge == nil {
|
|
return zero, false
|
|
}
|
|
svc := bridge.GetService(pluginName, serviceName)
|
|
if svc == nil {
|
|
return zero, false
|
|
}
|
|
typed, ok := svc.(T)
|
|
return typed, ok
|
|
}
|