shared

package
v0.0.0-...-45eb8e3 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 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:   "DEVICE_PLUGIN",
	MagicCookieValue: "device",
}

Handshake is a common handshake that is shared by plugin and host.

View Source
var PluginMap = map[string]plugin.Plugin{
	"device": &DevicePlugin{},
}

PluginMap is the map of plugins we can dispense.

Functions

This section is empty.

Types

type Device

type Device interface {
	CreateDevice() (uint64, error)
	FreeDevice(ptr uint64) error
	GetDevice(ptr uint64, useJson bool) ([]byte, error)
	DevicePrint(ptr uint64) error
	DeviceValue(ptr uint64) (int32, error)
	DeviceSetValue(ptr uint64, value int32) error
}

Device is the interface that we're exposing as a plugin.

type DevicePlugin

type DevicePlugin struct {
	plugin.NetRPCUnsupportedPlugin
	// Concrete implementation, written in Go. This is only used for plugins
	// that are written in Go.
	Impl Device
}

This is the implementation of plugin.Plugin so we can serve/consume this. We also implement GRPCPlugin so that this plugin can be served over gRPC.

func (*DevicePlugin) GRPCClient

func (p *DevicePlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*DevicePlugin) GRPCServer

func (p *DevicePlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type GRPCClient

type GRPCClient struct {
	// contains filtered or unexported fields
}

func (*GRPCClient) CreateDevice

func (m *GRPCClient) CreateDevice() (uint64, error)

func (*GRPCClient) DevicePrint

func (m *GRPCClient) DevicePrint(ptr uint64) error

func (*GRPCClient) DeviceSetValue

func (m *GRPCClient) DeviceSetValue(ptr uint64, value int32) error

func (*GRPCClient) DeviceValue

func (m *GRPCClient) DeviceValue(ptr uint64) (int32, error)

func (*GRPCClient) FreeDevice

func (m *GRPCClient) FreeDevice(ptr uint64) error

func (*GRPCClient) GetDevice

func (m *GRPCClient) GetDevice(ptr uint64, useJson bool) ([]byte, error)

type GRPCServer

type GRPCServer struct {
	Impl Device

	proto.UnimplementedDeviceServer
	// contains filtered or unexported fields
}

func (*GRPCServer) CreateDevice

func (*GRPCServer) DevicePrint

func (*GRPCServer) DeviceSetValue

func (*GRPCServer) DeviceValue

func (*GRPCServer) FreeDevice

func (*GRPCServer) GetDevice

Jump to

Keyboard shortcuts

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