diff --git a/internal/plugin/factory.go b/internal/plugin/factory.go index a3c84a1ff..17faf81d3 100644 --- a/internal/plugin/factory.go +++ b/internal/plugin/factory.go @@ -152,6 +152,12 @@ func RubyFactory( // Instance is the result generated by the factory. This lets us pack // a bit more information into plugin-launched components. type Instance struct { + // Plugin name providing this component + Name string + + // Type of component provided in this instance + Type component.Type + // Component is the dispensed component Component interface{} @@ -161,15 +167,22 @@ type Instance struct { // The GRPCBroker attached to this plugin Broker *plugin.GRPCBroker + // Parent component + Parent *Instance + // Closer is a function that should be called to clean up resources // associated with this plugin. Close func() } -type PluginMetadata interface { - SetRequestMetadata(k, v string) +func (i *Instance) Parents() []string { + n := []string{} + for p := i; p != nil; p = p.Parent { + n = append(n, p.Name) + } + return n } -type hasGRPCBroker interface { - GRPCBroker() *plugin.GRPCBroker +func (i *Instance) ParentCount() int { + return len(i.Parents()) }