shared

package
v0.0.0-...-1b8ef74 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package shared contains shared data between the host and plugins.

Index

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)

func (*GRPCClient) Open

func (m *GRPCClient) Open(host string, port uint32) error

func (*GRPCClient) Request

func (m *GRPCClient) Request(name string, data []byte) ([]byte, 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 (*GRPCServer) Open

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"`
}

Jump to

Keyboard shortcuts

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