shared

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MPL-2.0 Imports: 5 Imported by: 4

Documentation

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

PluginMap is the map of plugins we can dispense.

Functions

This section is empty.

Types

type Counter

type Counter interface {
	Increment(key string, value int64, storage Storage) (int64, error)
}

type CounterPlugin

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

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

func (*CounterPlugin) GRPCServer

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

type GRPCCounterClient

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

func (*GRPCCounterClient) Increment

func (m *GRPCCounterClient) Increment(key string, value int64, storage Storage) (int64, error)

type GRPCCounterServer

type GRPCCounterServer struct {
	proto.UnimplementedCounterServer
	Impl Counter
	// contains filtered or unexported fields
}

func (*GRPCCounterServer) Increment

type GRPCStorageClient

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

func (*GRPCStorageClient) Get

func (m *GRPCStorageClient) Get(key string) (int64, error)

func (*GRPCStorageClient) Put

func (m *GRPCStorageClient) Put(key string, value int64) error

type GRPCStorageServer

type GRPCStorageServer struct {
	proto.UnimplementedStorageServer
	Impl Storage
}

func (*GRPCStorageServer) Get

func (*GRPCStorageServer) Put

type Storage

type Storage interface {
	Put(key string, value int64) error
	Get(key string) (int64, error)
}

Jump to

Keyboard shortcuts

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