Help us shape the future of Go! Take the 2026 Go Developer Survey

grpc

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{

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

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

View Source
var PluginMap = map[string]plugin.Plugin{
	"model": &ModelGRPCPlugin{},
}

PluginMap is the map of plugins we can dispense.

Functions

This section is empty.

Types

type ClientGRPC

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

ClientGRPC is an implementation of KV that talks over RPC.

func (*ClientGRPC) Exec

func (m *ClientGRPC) Exec(name string, args ...interface{}) (*Response, error)

Exec execute the plugin model

type Model

type Model interface {
	Exec(name string, args ...interface{}) (*Response, error)
}

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

type ModelGRPCPlugin

type ModelGRPCPlugin 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 Model
}

ModelGRPCPlugin This is the implementation of plugin.Plugin so we can serve/consume this.

func (*ModelGRPCPlugin) GRPCClient

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

GRPCClient the GRPC client

func (*ModelGRPCPlugin) GRPCServer

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

GRPCServer the GRPC Server

type Response

type Response struct {
	Bytes []byte
}

Response GRPC Response

func (Response) Bind

func (res Response) Bind(v interface{}) error

Bind bind struct

func (Response) Map

func (res Response) Map() (maps.MapStrAny, error)

Map cast to map

func (Response) MustMap

func (res Response) MustMap() maps.MapStrAny

MustMap cast to map

type ServerGRPC

type ServerGRPC struct {
	// This is the real implementation
	Impl Model
}

ServerGRPC Here is the gRPC server that ClientGRPC talks to.

func (*ServerGRPC) Exec

func (m *ServerGRPC) Exec(ctx context.Context, req *proto.Request) (*proto.Response, error)

Exec ServerGet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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