Documentation ¶
Index ¶
- Constants
- type Connection
- type MockClient
- func (cli *MockClient) AddRoute(topic string, callback MQTT.MessageHandler)
- func (cli *MockClient) Connect() MQTT.Token
- func (cli *MockClient) Disconnect(quiesce uint)
- func (cli *MockClient) IsConnected() bool
- func (cli *MockClient) IsConnectionOpen() bool
- func (cli *MockClient) OptionsReader() MQTT.ClientOptionsReader
- func (cli *MockClient) Publish(topic string, qos byte, retained bool, payload interface{}) MQTT.Token
- func (cli *MockClient) Subscribe(topic string, qos byte, callback MQTT.MessageHandler) MQTT.Token
- func (cli *MockClient) SubscribeMultiple(filters map[string]byte, callback MQTT.MessageHandler) MQTT.Token
- func (cli *MockClient) Unsubscribe(topics ...string) MQTT.Token
- type MockMessage
- type MockToken
- type SubscribeAction
- func (act *SubscribeAction) Device(orgID, deviceID string) domain.PublishResponse
- func (act *SubscribeAction) SnapAck() domain.PublishResponse
- func (act *SubscribeAction) SnapConf() domain.PublishResponse
- func (act *SubscribeAction) SnapDisable() domain.PublishResponse
- func (act *SubscribeAction) SnapEnable() domain.PublishResponse
- func (act *SubscribeAction) SnapInfo() domain.PublishResponse
- func (act *SubscribeAction) SnapInstall() domain.PublishResponse
- func (act *SubscribeAction) SnapList(deviceID string) domain.PublishResponse
- func (act *SubscribeAction) SnapRefresh() domain.PublishResponse
- func (act *SubscribeAction) SnapRemove() domain.PublishResponse
- func (act *SubscribeAction) SnapRevert() domain.PublishResponse
- func (act *SubscribeAction) SnapServerVersion(deviceID string) domain.PublishResponse
- func (act *SubscribeAction) SnapSetConf() domain.PublishResponse
Constants ¶
const ( QOSAtMostOnce = byte(0) QOSAtLeastOnce = byte(1) )
Constants for connecting to the MQTT broker
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection for MQTT protocol
func GetConnection ¶
func GetConnection(enroll *domain.Enrollment) (*Connection, error)
GetConnection fetches or creates an MQTT connection
func (*Connection) Close ¶
func (c *Connection) Close()
Close closes the connection to the MQTT broker
func (*Connection) Health ¶
func (c *Connection) Health()
Health publishes a health message to indicate that the device is still active
func (*Connection) Metrics ¶
func (c *Connection) Metrics()
Metrics publishes a metrics messages to indicate so the device can be monitored
func (*Connection) SubscribeHandler ¶
func (c *Connection) SubscribeHandler(client MQTT.Client, msg MQTT.Message)
SubscribeHandler is the handler for the main subscription topic
func (*Connection) SubscribeToActions ¶
func (c *Connection) SubscribeToActions() error
SubscribeToActions subscribes to the action topic
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
MockClient mocks the MQTT client
func (*MockClient) AddRoute ¶
func (cli *MockClient) AddRoute(topic string, callback MQTT.MessageHandler)
AddRoute mocks routing
func (*MockClient) Connect ¶
func (cli *MockClient) Connect() MQTT.Token
Connect mocks connecting to broker
func (*MockClient) Disconnect ¶
func (cli *MockClient) Disconnect(quiesce uint)
Disconnect mocks client close
func (*MockClient) IsConnected ¶
func (cli *MockClient) IsConnected() bool
IsConnected mocks the connect status
func (*MockClient) IsConnectionOpen ¶
func (cli *MockClient) IsConnectionOpen() bool
IsConnectionOpen mocks the connect status
func (*MockClient) OptionsReader ¶
func (cli *MockClient) OptionsReader() MQTT.ClientOptionsReader
OptionsReader mocks the options reader (badly)
func (*MockClient) Publish ¶
func (cli *MockClient) Publish(topic string, qos byte, retained bool, payload interface{}) MQTT.Token
Publish mocks a publish message
func (*MockClient) Subscribe ¶
func (cli *MockClient) Subscribe(topic string, qos byte, callback MQTT.MessageHandler) MQTT.Token
Subscribe mocks a subscribe message
func (*MockClient) SubscribeMultiple ¶
func (cli *MockClient) SubscribeMultiple(filters map[string]byte, callback MQTT.MessageHandler) MQTT.Token
SubscribeMultiple mocks subscribe messages
func (*MockClient) Unsubscribe ¶
func (cli *MockClient) Unsubscribe(topics ...string) MQTT.Token
Unsubscribe mocks a unsubscribe message
type MockMessage ¶
type MockMessage struct {
// contains filtered or unexported fields
}
MockMessage implements an MQTT message
func (*MockMessage) Duplicate ¶
func (m *MockMessage) Duplicate() bool
Duplicate mocks a duplicate message check
func (*MockMessage) MessageID ¶
func (m *MockMessage) MessageID() uint16
MessageID mocks the message ID
func (*MockMessage) Payload ¶
func (m *MockMessage) Payload() []byte
Payload mocks the payload retrieval
func (*MockMessage) Retained ¶
func (m *MockMessage) Retained() bool
Retained mocks the retained flag
type SubscribeAction ¶
type SubscribeAction struct { ID string `json:"id"` Action string `json:"action"` Snap string `json:"snap"` Data string `json:"data"` }
SubscribeAction is the message format for the action topic
func (*SubscribeAction) Device ¶
func (act *SubscribeAction) Device(orgID, deviceID string) domain.PublishResponse
Device gets details of the device
func (*SubscribeAction) SnapAck ¶
func (act *SubscribeAction) SnapAck() domain.PublishResponse
SnapAck adds an assertion to the device
func (*SubscribeAction) SnapConf ¶
func (act *SubscribeAction) SnapConf() domain.PublishResponse
SnapConf gets the config for a snap
func (*SubscribeAction) SnapDisable ¶
func (act *SubscribeAction) SnapDisable() domain.PublishResponse
SnapDisable disables an existing snap
func (*SubscribeAction) SnapEnable ¶
func (act *SubscribeAction) SnapEnable() domain.PublishResponse
SnapEnable enables an existing snap
func (*SubscribeAction) SnapInfo ¶
func (act *SubscribeAction) SnapInfo() domain.PublishResponse
SnapInfo gets the info for a snap
func (*SubscribeAction) SnapInstall ¶
func (act *SubscribeAction) SnapInstall() domain.PublishResponse
SnapInstall installs a new snap
func (*SubscribeAction) SnapList ¶
func (act *SubscribeAction) SnapList(deviceID string) domain.PublishResponse
SnapList lists installed snaps
func (*SubscribeAction) SnapRefresh ¶
func (act *SubscribeAction) SnapRefresh() domain.PublishResponse
SnapRefresh refreshes an existing snap
func (*SubscribeAction) SnapRemove ¶
func (act *SubscribeAction) SnapRemove() domain.PublishResponse
SnapRemove removes an existing snap
func (*SubscribeAction) SnapRevert ¶
func (act *SubscribeAction) SnapRevert() domain.PublishResponse
SnapRevert reverts an existing snap
func (*SubscribeAction) SnapServerVersion ¶
func (act *SubscribeAction) SnapServerVersion(deviceID string) domain.PublishResponse
SnapServerVersion gets details of the device
func (*SubscribeAction) SnapSetConf ¶
func (act *SubscribeAction) SnapSetConf() domain.PublishResponse
SnapSetConf sets the config for a snap