Remove interfaces and add extra info to instance

This commit is contained in:
Chris Roberts 2021-12-17 14:48:54 -08:00 committed by Paul Hinze
parent 1db38e65f8
commit b2dec1191a
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -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())
}