shared

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MPL-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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": &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) Get

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

func (*GRPCClient) Put

func (m *GRPCClient) Put(key string, value []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) Get

func (*GRPCServer) Put

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

type KV

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 KVPlugin

type KVPlugin struct {
	// Plugin 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.Plugin so we can serve/consume this.

func (*KVPlugin) GRPCClient

func (p *KVPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (any, error)

func (*KVPlugin) GRPCServer

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

Jump to

Keyboard shortcuts

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