rpc

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: MPL-2.0 Imports: 14 Imported by: 1

Documentation

Overview

Package rpc contains the API that can be used to serve Sentinel plugins over an RPC interface. Sentinel supports consuming plugins across RPC with the requirement that the RPC must happen over a completely reliable network (effectively a local network).

## Object Plugins

Object plugins allow Sentinel values to be served over a plugin interface. This implements the object.External interface exported by lang/object.

There are limitations to the types of values that can be returned when this is served over a plugin:

  • All Go primitives and collections that the External interface allows may be returned, including structs.

  • All primitive and collection Object implementations may be returned.

  • ExternalObj, External may not yet be returned. We plan to allow this.

Index

Constants

View Source
const (
	ImportPluginName = "import"
)

The constants below are the names of the plugins that can be dispensed from the plugin server.

Variables

View Source
var Handshake = goplugin.HandshakeConfig{

	ProtocolVersion: 2,

	MagicCookieKey:   "SENTINEL_PLUGIN_MAGIC_COOKIE",
	MagicCookieValue: "2b7847b7b705781d7cf21a05e9c1bb37cbf078aea103bc3edcc6aca52ab65453",
}

Handshake is the HandshakeConfig used to configure clients and servers.

PluginMap should be used by clients for the map of plugins.

Functions

func Serve

func Serve(opts *ServeOpts)

Serve serves a plugin. This function never returns and should be the final function called in the main function of the plugin.

Types

type ImportFunc

type ImportFunc func() sdk.Import

type ImportGRPCClient

type ImportGRPCClient struct {
	Client proto.ImportClient
	// contains filtered or unexported fields
}

ImportGRPCClient is a gRPC server for Imports.

func (*ImportGRPCClient) Close

func (m *ImportGRPCClient) Close() error

func (*ImportGRPCClient) Configure

func (m *ImportGRPCClient) Configure(config map[string]interface{}) error

func (*ImportGRPCClient) Get

func (m *ImportGRPCClient) Get(rawReqs []*sdk.GetReq) ([]*sdk.GetResult, error)

type ImportGRPCServer

type ImportGRPCServer struct {
	F func() sdk.Import
	// contains filtered or unexported fields
}

ImportGRPCServer is a gRPC server for Imports.

func (*ImportGRPCServer) Close

func (m *ImportGRPCServer) Close(
	ctx context.Context, v *proto.Close_Request) (*proto.Empty, error)

func (*ImportGRPCServer) Configure

func (m *ImportGRPCServer) Configure(
	ctx context.Context, v *proto.Configure_Request) (*proto.Configure_Response, error)

func (*ImportGRPCServer) Get

func (m *ImportGRPCServer) Get(
	ctx context.Context, v *proto.Get_MultiRequest) (*proto.Get_MultiResponse, error)

type ImportPlugin

type ImportPlugin struct {
	goplugin.NetRPCUnsupportedPlugin

	F func() sdk.Import
}

ImportPlugin is the goplugin.Plugin implementation to serve sdk.Import.

func (*ImportPlugin) GRPCClient

func (p *ImportPlugin) GRPCClient(_ context.Context, _ *goplugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*ImportPlugin) GRPCServer

func (p *ImportPlugin) GRPCServer(_ *goplugin.GRPCBroker, s *grpc.Server) error

type ServeOpts

type ServeOpts struct {
	ImportFunc ImportFunc
}

ServeOpts are the configurations to serve a plugin.

Jump to

Keyboard shortcuts

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