plugins

package
v0.93.0-RC.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPluginOfWrongType  = errors.New("plugin of the wrong type")
	ErrPluginNameNotFound = errors.New("unknown plugin name")
)
View Source
var (
	Sound_name = map[int32]string{
		0: "PING",
		1: "PONG",
		2: "POING",
	}
	Sound_value = map[string]int32{
		"PING":  0,
		"PONG":  1,
		"POING": 2,
	}
)

Enum value maps for Sound.

View Source
var PingPong_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "pluginsTest.PingPongPlayer",
	HandlerType: (*PingPongServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Ping",
			Handler:    _PingPong_Ping_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "test.proto",
}

PingPong_ServiceDesc is the grpc.ServiceDesc for PingPongPlayer service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterPingPongServer

func RegisterPingPongServer(s grpc.ServiceRegistrar, srv PingPongServer)

Types

type GRPCPlugin

type GRPCPlugin struct {
	Impl PingPongStub
	plugin.Plugin
}

func (GRPCPlugin) GRPCClient

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

GRPCClient will return the Delta diff GRPC custom client

func (GRPCPlugin) GRPCServer

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

type HClogger

type HClogger struct {
	hclog.Logger
	// contains filtered or unexported fields
}

func NewHClogger

func NewHClogger(hcl hclog.Logger, logger logging.Logger) HClogger

func (HClogger) Debug

func (l HClogger) Debug(msg string, args ...interface{})

func (HClogger) Error

func (l HClogger) Error(msg string, args ...interface{})

func (HClogger) Info

func (l HClogger) Info(msg string, args ...interface{})

func (HClogger) IsDebug

func (l HClogger) IsDebug() bool

func (HClogger) IsError

func (l HClogger) IsError() bool

func (HClogger) IsInfo

func (l HClogger) IsInfo() bool

func (HClogger) IsTrace

func (l HClogger) IsTrace() bool

func (HClogger) IsWarn

func (l HClogger) IsWarn() bool

func (HClogger) Log

func (l HClogger) Log(level hclog.Level, msg string, args ...interface{})

func (HClogger) SetLevel

func (l HClogger) SetLevel(level hclog.Level)

func (HClogger) Trace

func (l HClogger) Trace(msg string, args ...interface{})

func (HClogger) Warn

func (l HClogger) Warn(msg string, args ...interface{})

type Manager

type Manager[T any] struct {
	// contains filtered or unexported fields
}

Manager maps the available plugin names to the different kinds of plugin.Client plugin controllers. T is the custom interface type that the returned GRPCClient implementation implements, e.g. "Differ" for `plugin.Client`s that

include a GRPCClient that implements the "Differ" interface:
grpcPluginClient, err := c.Client() // Returns a plugin.GRPCClient
rawGrpcClientStub, err := grpcPluginClient.Dispense(name) // Calls grpcPluginClient's GRPCClient method and returns the gRPC stub.
grpcClient, ok := rawGrpcClientStub.(Differ) // Asserts the expected type of stub client.

The map might include a mapping of "delta" -> plugin.Client to communicate with the Delta plugin.

func NewManager

func NewManager[T any]() *Manager[T]

func (*Manager[T]) LoadPluginClient

func (m *Manager[T]) LoadPluginClient(name string) (T, error)

LoadPluginClient loads a Client of type T.

func (*Manager[T]) RegisterPlugin

func (m *Manager[T]) RegisterPlugin(name string, id PluginIdentity, auth PluginHandshake, p plugin.Plugin)

RegisterPlugin registers a new plugin client with the corresponding plugin type.

type NopGRPCPlugin

type NopGRPCPlugin struct {
	plugin.Plugin
}

func (NopGRPCPlugin) GRPCClient

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

func (NopGRPCPlugin) GRPCServer

func (np NopGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type PingPongClient

type PingPongClient interface {
	Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PongResponse, error)
}

PingPongClient is the client API for PingPongPlayer service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewPingPongClient

func NewPingPongClient(cc grpc.ClientConnInterface) PingPongClient

type PingPongPlayer

type PingPongPlayer struct{}

func (*PingPongPlayer) Play

Play is the actual implementation of the function that the server will use

type PingPongServer

type PingPongServer interface {
	Ping(context.Context, *PingRequest) (*PongResponse, error)
	// contains filtered or unexported methods
}

PingPongServer is the server API for PingPongPlayer service. All implementations must embed UnimplementedPingPongServer for forward compatibility

type PingPongSound

type PingPongSound int32
const (
	PING PingPongSound = iota
	PONG
	POING
	BOOM
)

type PingPongStub

type PingPongStub interface {
	Play(PingPongSound) PingPongSound
}

type PingRequest

type PingRequest struct {
	Sound Sound `protobuf:"varint,1,opt,name=sound,proto3,enum=pluginsTest.Sound" json:"sound,omitempty"`
	// contains filtered or unexported fields
}

func (*PingRequest) Descriptor deprecated

func (*PingRequest) Descriptor() ([]byte, []int)

Deprecated: Use PingRequest.ProtoReflect.Descriptor instead.

func (*PingRequest) GetSound

func (x *PingRequest) GetSound() Sound

func (*PingRequest) ProtoMessage

func (*PingRequest) ProtoMessage()

func (*PingRequest) ProtoReflect

func (x *PingRequest) ProtoReflect() protoreflect.Message

func (*PingRequest) Reset

func (x *PingRequest) Reset()

func (*PingRequest) String

func (x *PingRequest) String() string

type PluginHandshake

type PluginHandshake struct {
	Key   string
	Value string
}

PluginHandshake includes handshake properties for the plugin.

type PluginIdentity

type PluginIdentity struct {
	ProtocolVersion uint
	// Cmd is the command that is used to run the plugin executable on the local filesystem.
	Cmd exec.Cmd
}

PluginIdentity identifies the plugin's version and executable location.

type PongResponse

type PongResponse struct {
	Sound Sound `protobuf:"varint,1,opt,name=sound,proto3,enum=pluginsTest.Sound" json:"sound,omitempty"`
	// contains filtered or unexported fields
}

func (*PongResponse) Descriptor deprecated

func (*PongResponse) Descriptor() ([]byte, []int)

Deprecated: Use PongResponse.ProtoReflect.Descriptor instead.

func (*PongResponse) GetSound

func (x *PongResponse) GetSound() Sound

func (*PongResponse) ProtoMessage

func (*PongResponse) ProtoMessage()

func (*PongResponse) ProtoReflect

func (x *PongResponse) ProtoReflect() protoreflect.Message

func (*PongResponse) Reset

func (x *PongResponse) Reset()

func (*PongResponse) String

func (x *PongResponse) String() string

type Sound

type Sound int32
const (
	Sound_PING  Sound = 0
	Sound_PONG  Sound = 1
	Sound_POING Sound = 2
)

func (Sound) Descriptor

func (Sound) Descriptor() protoreflect.EnumDescriptor

func (Sound) Enum

func (x Sound) Enum() *Sound

func (Sound) EnumDescriptor deprecated

func (Sound) EnumDescriptor() ([]byte, []int)

Deprecated: Use Sound.Descriptor instead.

func (Sound) Number

func (x Sound) Number() protoreflect.EnumNumber

func (Sound) String

func (x Sound) String() string

func (Sound) Type

func (Sound) Type() protoreflect.EnumType

type TestGRPCClient

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

TestGRPCClient is the implementation of our GRPC client. It should implement the PingPongStub interface and use the Protobuf service client (PingPongClient) to perform the call to the server.

func (*TestGRPCClient) Play

type TestGRPCServer

type TestGRPCServer struct {
	Impl PingPongStub
}

TestGRPCServer is the implementation of our GRPC service. It should implement the Protobuf service server's interface (PingPongServer).

func (*TestGRPCServer) Ping

func (t *TestGRPCServer) Ping(ctx context.Context, request *PingRequest) (*PongResponse, error)

type UnimplementedPingPongServer

type UnimplementedPingPongServer struct {
}

UnimplementedPingPongServer must be embedded to have forward compatible implementations.

func (UnimplementedPingPongServer) Ping

type UnsafePingPongServer

type UnsafePingPongServer interface {
	// contains filtered or unexported methods
}

UnsafePingPongServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to PingPongServer will result in compilation errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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