Documentation
¶
Index ¶
- Variables
- func RegisterPingPongServer(s grpc.ServiceRegistrar, srv PingPongServer)
- func RunPluginServer(key, value string, v int)
- type Client
- type GRPCPlugin
- type HCPluginProperties
- 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 Handler
- type Manager
- type NopGRPCPlugin
- type PingPongClient
- type PingPongPlayer
- type PingPongServer
- type PingPongSound
- type PingPongStub
- type PingRequest
- 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") ErrPluginNotFound = errors.New("unknown plugin Client") )
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)
func RunPluginServer ¶
Types ¶
type Client ¶
type Client struct { PluginClient *plugin.Client ClientProps *HCPluginProperties }
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 HCPluginProperties ¶
type HCPluginProperties struct { ID plugins.PluginIdentity Handshake plugins.PluginHandshake P plugin.Plugin }
type HClogger ¶
type HClogger struct { hclog.Logger // contains filtered or unexported fields }
func NewHClogger ¶
type Handler ¶
type Handler[T, I any] interface { RegisterPlugin(string, I) LoadPluginClient(string) (T, func(), error) Plugins() []string }
Handler is an interface used to handle the different plugin implementation. T is the custom interface that the plugins implement. I is the type of input properties needed to support the plugin. Look at Manager to get an example of an implementation for this interface.
type Manager ¶
type Manager[T any] struct { // contains filtered or unexported fields }
Manager holds a clientStore and is responsible to register and unregister `plugin.Client`s, and to load the underlying GRPC Client. T is the custom interface type that the returned GRPC Client 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.
func NewManager ¶
func (*Manager[T]) LoadPluginClient ¶
LoadPluginClient returns a GRPCClient which also implements the custom plugin interface T. The returned function is used to close the Client and reset it. The reset is needed because after plugin.Client.Client() is called, it's internally creating channels that are closed when we Kill the Client, and won't allow to run the Client again. The close function should be called when the plugin is no longer of use.
func (*Manager[T]) RegisterPlugin ¶
func (m *Manager[T]) RegisterPlugin(name string, props HCPluginProperties)
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 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.