{"modulePath":"github.com/GoCodeAlone/go-plugin","version":"v1.7.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package shared\n\nPackage shared contains shared data between the host and plugins.\n\n## Variables\n\n```go\nvar Handshake = plugin.HandshakeConfig{\n\n\tProtocolVersion:  1,\n\tMagicCookieKey:   \"BASIC_PLUGIN\",\n\tMagicCookieValue: \"hello\",\n}\n```\nHandshake is a common handshake that is shared by plugin and host.\n\n```go\nvar PluginMap = map[string]plugin.Plugin{\n\t\"kv_grpc\": \u0026KVPlugin{},\n}\n```\nPluginMap is the map of plugins we can dispense.\n\n## Types\n\n```go\ntype GRPCClient struct {\n\t// contains filtered or unexported fields\n}\n```\nGRPCClient is an implementation of KV that talks over RPC.\n\n```go\nfunc (m *GRPCClient) Get(key string) ([]byte, error)\n```\n\n```go\nfunc (m *GRPCClient) Put(key string, value []byte) error\n```\n\n```go\ntype GRPCServer struct {\n\t// This is the real implementation\n\tImpl KV\n}\n```\nHere is the gRPC server that GRPCClient talks to.\n\n```go\nfunc (m *GRPCServer) Get(\n\tctx context.Context,\n\treq *proto.GetRequest) (*proto.GetResponse, error)\n```\n\n```go\nfunc (m *GRPCServer) Put(\n\tctx context.Context,\n\treq *proto.PutRequest) (*proto.Empty, error)\n```\n\n```go\ntype KV interface {\n\tPut(key string, value []byte) error\n\tGet(key string) ([]byte, error)\n}\n```\nKV is the interface that we're exposing as a plugin.\n\n```go\ntype KVPlugin struct {\n\t// Plugin must still implement the Plugin interface\n\tplugin.Plugin\n\t// Concrete implementation, written in Go. This is only used for plugins\n\t// that are written in Go.\n\tImpl KV\n}\n```\nThis is the implementation of plugin.Plugin so we can serve/consume this.\n\n```go\nfunc (p *KVPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (any, error)\n```\n\n```go\nfunc (p *KVPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error\n```\n\n","path":"github.com/GoCodeAlone/go-plugin/examples/grpc/shared","name":"shared","synopsis":"Package shared contains shared data between the host and plugins.","isRedistributable":true}
