shared

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2020 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Package shared contains shared data between the host and plugins.

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{

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

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

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

PluginMap is the map of plugins we can dispense.

Functions

This section is empty.

Types

type GRPCClient

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

GRPCClient is an implementation of KV that talks over RPC.

func (*GRPCClient) Execute

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

type GRPCServer

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

Here is the gRPC server that GRPCClient talks to.

func (*GRPCServer) Execute

func (m *GRPCServer) Execute(
	ctx context.Context,
	req *proto.TumboRequest) (*proto.TumboResponse, error)

type KV

type KV interface {
	Execute(key string) ([]byte, error)
}

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

type KVGRPCPlugin

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

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

func (*KVGRPCPlugin) GRPCServer

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

type KVPlugin

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

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

func (*KVPlugin) Server

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

type RPCClient

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

RPCClient is an implementation of KV that talks over RPC.

func (*RPCClient) Get

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

func (*RPCClient) Put

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

type RPCServer

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) Execute

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL