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: "BeeThings",
}
Handshake is a common handshake that is shared by plugin and host.
View Source
var PluginMap = map[string]plugin.Plugin{ "converter": &ConverterPlugin{}, }
PluginMap is the map of plugins we can dispense.
Functions ¶
This section is empty.
Types ¶
type Converter ¶
type Converter interface { // ConvertIssueMessage2Device converts issue request to protocol that device understands, which has four return parameters: // 1. inputMessages: device issue protocols for each of command input param. // 2. outputMessages: device data report protocols for each of command output param. // 3. issueTopic: device issue MQTT topic for input params. // 4. issueResponseTopic: device issue response MQ topic for output params. ConvertIssueMessage2Device(deviceId, modelId, featureId string, values map[string]string, convertedDeviceFeatureMap string) ([]string, []string, string, string, error) // ConvertDeviceMessages2MQFormat receives device command issue responses and converts it to RabbitMQ normative format. ConvertDeviceMessages2MQFormat(messages []string, convertedDeviceFeatureMap string) (string, []byte, error) }
Converter is the interface that we're exposing as a plugin.
type ConverterPlugin ¶
type ConverterPlugin struct { plugin.NetRPCUnsupportedPlugin // Concrete implementation, written in Go. This is only used for plugins // that are written in Go. Impl Converter }
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 (*ConverterPlugin) GRPCClient ¶
func (p *ConverterPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
func (*ConverterPlugin) GRPCServer ¶
func (p *ConverterPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type GRPCClient ¶
type GRPCClient struct {
// contains filtered or unexported fields
}
GRPCClient is an implementation of Converter that talks over RPC.
func (*GRPCClient) ConvertDeviceMessages2MQFormat ¶
type GRPCServer ¶
type GRPCServer struct { // This is the real implementation Impl Converter // contains filtered or unexported fields }
Here is the gRPC server that GRPCClient talks to.
func (*GRPCServer) ConvertDeviceMessages2MQFormat ¶
func (m *GRPCServer) ConvertDeviceMessages2MQFormat(ctx context.Context, req *proto.GetMQFormatRequest) (*proto.GetMQFormatResponse, error)
func (*GRPCServer) ConvertIssueMessage2Device ¶
func (m *GRPCServer) ConvertIssueMessage2Device(ctx context.Context, req *proto.GetDeviceIssueRequest) (*proto.GetDeviceIssueResponse, error)
Click to show internal directories.
Click to hide internal directories.