hashicorp / go-plugin

Golang plugin system over RPC.
Mozilla Public License 2.0
5.25k stars 450 forks source link

Use of interfaces #148

Open mytototo opened 4 years ago

mytototo commented 4 years ago

Hi,

I am migrating Go plugins to this library because there are too many drawbacks using the standard library.

Is it possible for functions of interfaces to return another interface living in the same plugin? If so, how does the common RPC client look like?

How can I pass several args down to the plugin?

I have a common interface like this:

type Example interface {
  InternalOtherInterface(arg1 string, arg2 string) InternalOtherInterface
}

Using the RPC client I usually write something like this (when not returning interface):

func (p *PluginClient) InternalOtherInterface() InternalOtherInterface {
    var oa OtherInterface

    err := p.client.Call("Plugin.InternalOtherInterface", new(interface{}), &oa)
    if err != nil {
        ///
    }

    ///

    return oa
}

The error provoking the panic is the following:

rpc: gob error encoding body: gob: type not registered for interface: main.internalotherinterface

Thank you for your time.

EDIT: Add question about args.

sh0umik commented 1 year ago

@mytototo I am having a similar problem and trying to do the same thing. Did you find any solution or any answer for me?