{"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\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\"counter\": \u0026CounterPlugin{},\n}\n```\nPluginMap is the map of plugins we can dispense.\n\n## Types\n\n```go\ntype AddHelper interface {\n\tSum(int64, int64) (int64, error)\n}\n```\n\n```go\ntype Counter interface {\n\tPut(key string, value int64, a AddHelper) error\n\tGet(key string) (int64, error)\n}\n```\nKV is the interface that we're exposing as a plugin.\n\n```go\ntype CounterPlugin struct {\n\t// Concrete implementation, written in Go. This is only used for plugins\n\t// that are written in Go.\n\tImpl Counter\n}\n```\nThis is the implementation of plugin.Plugin so we can serve/consume this. We also implement Plugin so that this plugin can be served over gRPC.\n\n```go\nfunc (p *CounterPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (any, error)\n```\n\n```go\nfunc (p *CounterPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error\n```\n\n```go\ntype GRPCAddHelperClient 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 *GRPCAddHelperClient) Sum(a, b int64) (int64, error)\n```\n\n```go\ntype GRPCAddHelperServer struct {\n\t// This is the real implementation\n\tImpl AddHelper\n}\n```\nHere is the gRPC server that GRPCClient talks to.\n\n```go\nfunc (m *GRPCAddHelperServer) Sum(ctx context.Context, req *proto.SumRequest) (resp *proto.SumResponse, err error)\n```\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) (int64, error)\n```\n\n```go\nfunc (m *GRPCClient) Put(key string, value int64, a AddHelper) error\n```\n\n```go\ntype GRPCServer struct {\n\t// This is the real implementation\n\tImpl Counter\n\t// contains filtered or unexported fields\n}\n```\nHere is the gRPC server that GRPCClient talks to.\n\n```go\nfunc (m *GRPCServer) Get(ctx context.Context, req *proto.GetRequest) (*proto.GetResponse, error)\n```\n\n```go\nfunc (m *GRPCServer) Put(ctx context.Context, req *proto.PutRequest) (*proto.Empty, error)\n```\n\n","path":"github.com/GoCodeAlone/go-plugin/examples/bidirectional/shared","name":"shared","synopsis":"Package shared contains shared data between the host and plugins.","isRedistributable":true}
