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

package shared

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

Package shared contains shared data between the host and plugins.

Index

Package Files

grpc.go interface.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{
    "counter": &CounterPlugin{},
}

PluginMap is the map of plugins we can dispense.

type AddHelper Uses

type AddHelper interface {
    Sum(int64, int64) (int64, error)
}

type Counter Uses

type Counter interface {
    Put(key string, value int64, a AddHelper) error
    Get(key string) (int64, error)
}

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

type CounterPlugin Uses

type CounterPlugin struct {
    plugin.NetRPCUnsupportedPlugin
    // Concrete implementation, written in Go. This is only used for plugins
    // that are written in Go.
    Impl Counter
}

This is the implementation of plugin.Plugin so we can serve/consume this. We also implement GRPCPlugin so that this plugin can be served over gRPC.

func (*CounterPlugin) GRPCClient Uses

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

func (*CounterPlugin) GRPCServer Uses

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

type GRPCAddHelperClient Uses

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

GRPCClient is an implementation of KV that talks over RPC.

func (*GRPCAddHelperClient) Sum Uses

func (m *GRPCAddHelperClient) Sum(a, b int64) (int64, error)

type GRPCAddHelperServer Uses

type GRPCAddHelperServer struct {
    // This is the real implementation
    Impl AddHelper
}

Here is the gRPC server that GRPCClient talks to.

func (*GRPCAddHelperServer) Sum Uses

func (m *GRPCAddHelperServer) Sum(ctx context.Context, req *proto.SumRequest) (resp *proto.SumResponse, err error)

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) (int64, error)

func (*GRPCClient) Put Uses

func (m *GRPCClient) Put(key string, value int64, a AddHelper) error

type GRPCServer Uses

type GRPCServer struct {
    // This is the real implementation
    Impl Counter
    // contains filtered or unexported fields
}

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)

Package shared imports 5 packages (graph) and is imported by 2 packages. Updated 2018-02-25. Refresh now. Tools for package owners.