go-plugin: github.com/hashicorp/go-plugin/examples/grpc/shared Index | Files

package shared

import "github.com/hashicorp/go-plugin/examples/grpc/shared"

Package shared contains shared data between the host and plugins.

Index

Package Files

grpc.go interface.go rpc.go

Variables

var Handshake = plugin.HandshakeConfig{

    ProtocolVersion:  1,
    MagicCookieKey:   "BASIC_PLUGIN",
    MagicCookieValue: "hello",
}

Handshake is a common handshake that is shared by plugin and host.

var PluginMap = map[string]plugin.Plugin{
    "kv_grpc": &KVGRPCPlugin{},
    "kv":      &KVPlugin{},
}

PluginMap is the map of plugins we can dispense.

type GRPCClient Uses

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

GRPCClient is an implementation of KV that talks over RPC.

func (*GRPCClient) Get Uses

func (m *GRPCClient) Get(key string) ([]byte, error)

func (*GRPCClient) Put Uses

func (m *GRPCClient) Put(key string, value []byte) error

type GRPCServer Uses

type GRPCServer struct {
    // This is the real implementation
    Impl KV
}

Here is the gRPC server that GRPCClient talks to.

func (*GRPCServer) Get Uses

func (m *GRPCServer) Get(
    ctx context.Context,
    req *proto.GetRequest) (*proto.GetResponse, error)

func (*GRPCServer) Put Uses

func (m *GRPCServer) Put(
    ctx context.Context,
    req *proto.PutRequest) (*proto.Empty, error)

type KV Uses

type KV interface {
    Put(key string, value []byte) error
    Get(key string) ([]byte, error)
}

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

type KVGRPCPlugin Uses

type KVGRPCPlugin struct {
    // GRPCPlugin must still implement the Plugin interface
    plugin.Plugin
    // Concrete implementation, written in Go. This is only used for plugins
    // that are written in Go.
    Impl KV
}

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

func (*KVGRPCPlugin) GRPCClient Uses

func (p *KVGRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*KVGRPCPlugin) GRPCServer Uses

func (p *KVGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type KVPlugin Uses

type KVPlugin struct {
    // Concrete implementation, written in Go. This is only used for plugins
    // that are written in Go.
    Impl KV
}

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

func (*KVPlugin) Client Uses

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

func (*KVPlugin) Server Uses

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

type RPCClient Uses

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

RPCClient is an implementation of KV that talks over RPC.

func (*RPCClient) Get Uses

func (m *RPCClient) Get(key string) ([]byte, error)

func (*RPCClient) Put Uses

func (m *RPCClient) Put(key string, value []byte) error

type RPCServer Uses

type RPCServer struct {
    // This is the real implementation
    Impl KV
}

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

func (*RPCServer) Get Uses

func (m *RPCServer) Get(key string, resp *[]byte) error

func (*RPCServer) Put Uses

func (m *RPCServer) Put(args map[string]interface{}, resp *interface{}) error

Package shared imports 6 packages (graph) and is imported by 5 packages. Updated 2018-10-11. Refresh now. Tools for package owners.