Documentation ¶
Index ¶
- Variables
- func RegisterPingPongServer(s grpc.ServiceRegistrar, srv PingPongServer)
- type GRPCPlugin
- type HClogger
- func (l HClogger) Debug(msg string, args ...interface{})
- func (l HClogger) Error(msg string, args ...interface{})
- func (l HClogger) Info(msg string, args ...interface{})
- func (l HClogger) IsDebug() bool
- func (l HClogger) IsError() bool
- func (l HClogger) IsInfo() bool
- func (l HClogger) IsTrace() bool
- func (l HClogger) IsWarn() bool
- func (l HClogger) Log(level hclog.Level, msg string, args ...interface{})
- func (l HClogger) SetLevel(level hclog.Level)
- func (l HClogger) Trace(msg string, args ...interface{})
- func (l HClogger) Warn(msg string, args ...interface{})
- type Manager
- type NopGRPCPlugin
- type PingPongClient
- type PingPongPlayer
- type PingPongServer
- type PingPongSound
- type PingPongStub
- type PingRequest
- type PluginHandshake
- type PluginIdentity
- type PongResponse
- type Sound
- type TestGRPCClient
- type TestGRPCServer
- type UnimplementedPingPongServer
- type UnsafePingPongServer
Constants ¶
This section is empty.
Variables ¶
var ( ErrPluginOfWrongType = errors.New("plugin of the wrong type") ErrPluginNameNotFound = errors.New("unknown plugin name") )
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.
var File_test_proto protoreflect.FileDescriptor
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 ¶
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 (*Manager[T]) LoadPluginClient ¶
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 ¶
func (*PingPongPlayer) Play(pps PingPongSound) PingPongSound
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 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 ¶
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
func (Sound) Descriptor ¶
func (Sound) Descriptor() protoreflect.EnumDescriptor
func (Sound) EnumDescriptor
deprecated
func (Sound) Number ¶
func (x Sound) Number() protoreflect.EnumNumber
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 ¶
func (t *TestGRPCClient) Play(sound PingPongSound) PingPongSound
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 ¶
func (UnimplementedPingPongServer) Ping(context.Context, *PingRequest) (*PongResponse, error)
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.