grpc

package
v0.0.0-...-fbaabe3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "GOU_MODEL_PLUGIN",
	MagicCookieValue: "GOU VER0.6.0",
}
View Source
var PluginMap = map[string]plugin.Plugin{
	"model": &ModelGRPCPlugin{},
}

Functions

func Serve

func Serve(model Model)

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 Level

type Level int32
const (
	NoLevel Level = 0
	Trace   Level = 1
	Debug   Level = 2
	Info    Level = 3
	Warn    Level = 4
	Error   Level = 5
	Off     Level = 6
)

type Model

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

type ModelGRPCPlugin

type ModelGRPCPlugin struct {
	plugin.Plugin
	Impl Model
}

func (*ModelGRPCPlugin) GRPCClient

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

func (*ModelGRPCPlugin) GRPCServer

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

type Plugin

type Plugin struct {
	Logger hclog.Logger
}

func (*Plugin) SetLogger

func (plugin *Plugin) SetLogger(output io.Writer, level Level)

type Response

type Response struct {
	Bytes []byte
	Type  string
}

func (Response) Array

func (res Response) Array() ([]interface{}, error)

func (Response) Bind

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

func (Response) Interface

func (res Response) Interface() (interface{}, error)

func (Response) Map

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

func (Response) MustArray

func (res Response) MustArray() []interface{}

func (Response) MustBind

func (res Response) MustBind(v interface{})

func (Response) MustInterface

func (res Response) MustInterface() interface{}

func (Response) MustMap

func (res Response) MustMap() maps.MapStrAny

func (Response) MustValue

func (res Response) MustValue() interface{}

func (Response) Value

func (res Response) Value() (interface{}, error)

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