go-plugin: github.com/hashicorp/go-plugin/examples/basic/commons Index | Files

package example

import "github.com/hashicorp/go-plugin/examples/basic/commons"

Index

Package Files

greeter_interface.go

type Greeter Uses

type Greeter interface {
    Greet() string
}

Greeter is the interface that we're exposing as a plugin.

type GreeterPlugin Uses

type GreeterPlugin struct {
    // Impl Injection
    Impl Greeter
}

This is the implementation of plugin.Plugin so we can serve/consume this

This has two methods: Server must return an RPC server for this plugin type. We construct a GreeterRPCServer for this.

Client must return an implementation of our interface that communicates over an RPC client. We return GreeterRPC for this.

Ignore MuxBroker. That is used to create more multiplexed streams on our plugin connection and is a more advanced use case.

func (GreeterPlugin) Client Uses

func (GreeterPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*GreeterPlugin) Server Uses

func (p *GreeterPlugin) Server(*plugin.MuxBroker) (interface{}, error)

type GreeterRPC Uses

type GreeterRPC struct {
    // contains filtered or unexported fields
}

Here is an implementation that talks over RPC

func (*GreeterRPC) Greet Uses

func (g *GreeterRPC) Greet() string

type GreeterRPCServer Uses

type GreeterRPCServer struct {
    // This is the real implementation
    Impl Greeter
}

Here is the RPC server that GreeterRPC talks to, conforming to the requirements of net/rpc

func (*GreeterRPCServer) Greet Uses

func (s *GreeterRPCServer) Greet(args interface{}, resp *string) error

Package example imports 2 packages (graph) and is imported by 2 packages. Updated 2017-04-26. Refresh now. Tools for package owners.