internal

package
v0.96.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPluginOfWrongType = errors.New("plugin of the wrong type")
	ErrPluginNotFound    = errors.New("unknown plugin Client")
)
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)

func RunPluginServer

func RunPluginServer(key, value string, v int)

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

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 Handler

type Handler[T, I any] interface {
	RegisterPlugin(string, I)
	LoadPluginClient(string) (T, func(), error)
}

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 NewManager[T any]() *Manager[T]

func (*Manager[T]) LoadPluginClient

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

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

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 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.

Jump to

Keyboard shortcuts

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