Documentation ¶
Overview ¶
Package shared contains shared data between the host and plugins.
Index ¶
- Variables
- type GRPCClient
- type GRPCServer
- func (m *GRPCServer) Close(ctx context.Context, req *proto.EmptyRequest) (*proto.CloseResponse, error)
- func (m *GRPCServer) Open(ctx context.Context, req *proto.OpenRequest) (*proto.EmptyResponse, error)
- func (m *GRPCServer) Request(ctx context.Context, req *proto.GameRequest) (*proto.GameResponse, error)
- type Game
- type GameGRPCPlugin
- type GameRequest
- type GameResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var Handshake = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "GAME_PLUGIN",
MagicCookieValue: "eyotang",
}
Handshake is a common handshake that is shared by plugin and host.
View Source
var PluginMap = map[string]plugin.Plugin{ "game_grpc": &GameGRPCPlugin{}, }
PluginMap is the map of plugins we can dispense.
Functions ¶
This section is empty.
Types ¶
type GRPCClient ¶
type GRPCClient struct {
// contains filtered or unexported fields
}
GRPCClient is an implementation of Game that talks over RPC.
func (*GRPCClient) Close ¶
func (m *GRPCClient) Close() (string, error)
type GRPCServer ¶
type GRPCServer struct { // This is the real implementation Impl Game }
Here is the gRPC server that GRPCClient talks to.
func (*GRPCServer) Close ¶
func (m *GRPCServer) Close( ctx context.Context, req *proto.EmptyRequest) (*proto.CloseResponse, error)
func (*GRPCServer) Open ¶
func (m *GRPCServer) Open( ctx context.Context, req *proto.OpenRequest) (*proto.EmptyResponse, error)
func (*GRPCServer) Request ¶
func (m *GRPCServer) Request( ctx context.Context, req *proto.GameRequest) (*proto.GameResponse, error)
type Game ¶
type Game interface { Open(host string, port uint32) error Close() (string, error) Request(name string, data []byte) ([]byte, error) }
Game is the interface that we're exposing as a plugin.
type GameGRPCPlugin ¶
type GameGRPCPlugin struct { // GRPCPlugin must still implement the Plugin interface plugin.Plugin // Concrete implementation, written in Go. This is only used for plugins // that are written in Go. Impl Game }
This is the implementation of plugin.GRPCPlugin so we can serve/consume this.
func (*GameGRPCPlugin) GRPCClient ¶
func (p *GameGRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
func (*GameGRPCPlugin) GRPCServer ¶
func (p *GameGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type GameRequest ¶
type GameRequest struct { RspCmd int32 `json:"rspCmd" binding:"required"` Data interface{} `json:"data" binding:"required"` }
type GameResponse ¶
type GameResponse struct { Name string `json:"name"` Data interface{} `json:"data"` }
Click to show internal directories.
Click to hide internal directories.