Remove interfaces and add extra info to instance
This commit is contained in:
parent
1db38e65f8
commit
b2dec1191a
@ -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())
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user