Documentation ¶
Overview ¶
Package bus contains service bus abstractions.
Index ¶
- func NewServiceBusProvider(ctor *ConstructBus) (providers.IBusProvider, error)
- type ConstructBus
- type DeviceAssignment
- type DeviceAssignmentMessage
- type DeviceCommandMessage
- type DeviceUpdateMessage
- type DiscoveryMessage
- type EntityLoadStatusMessage
- type ErrCorruptedMessage
- type ErrOldMessage
- type ErrUnknownType
- type IMasterMessageParserProvider
- type IMessageParserProvider
- type IWorkerMessageParserProvider
- type KeyValue
- type MessageWithType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewServiceBusProvider ¶
func NewServiceBusProvider(ctor *ConstructBus) (providers.IBusProvider, error)
NewServiceBusProvider constructs a new service bus provider.
Types ¶
type ConstructBus ¶
type ConstructBus struct { Provider string Loader providers.IPluginLoaderProvider RawConfig []byte Logger common.ILoggerProvider NodeID string Secret common.ISecretProvider }
ConstructBus holds values required for a new service bus provider.
type DeviceAssignment ¶
type DeviceAssignment struct { Plugin string `json:"p"` Type enums.DeviceType `json:"t"` Config string `json:"c"` Name string `json:"n"` IsAPI bool `json:"a"` LoadFinished bool `json:"-"` CancelLoading bool `json:"-"` }
DeviceAssignment type with single device assignment.
type DeviceAssignmentMessage ¶
type DeviceAssignmentMessage struct { MessageWithType Devices []*DeviceAssignment `json:"d"` UOM enums.UOM `json:"u"` }
DeviceAssignmentMessage used by server to send a new set of devices to worker.
func NewDeviceAssignmentMessage ¶
func NewDeviceAssignmentMessage(devices []*DeviceAssignment, uom enums.UOM) *DeviceAssignmentMessage
NewDeviceAssignmentMessage constructs device assignment message.
type DeviceCommandMessage ¶
type DeviceCommandMessage struct { MessageWithType DeviceID string `json:"i"` Command enums.Command `json:"c"` Payload map[string]interface{} `json:"p"` }
DeviceCommandMessage used by server to invoke device command on a worker.
func NewDeviceCommandMessage ¶
func NewDeviceCommandMessage(deviceID string, command enums.Command, data map[string]interface{}) *DeviceCommandMessage
NewDeviceCommandMessage constructs device command message.
type DeviceUpdateMessage ¶
type DeviceUpdateMessage struct { MessageWithType DeviceType enums.DeviceType `json:"t"` DeviceID string `json:"i"` State map[string]interface{} `json:"s"` Commands []string `json:"o"` WorkerID string `json:"w"` DeviceName string `json:"n"` }
DeviceUpdateMessage used by worker to update service with devices state update.
func NewDeviceUpdateMessage ¶
func NewDeviceUpdateMessage() *DeviceUpdateMessage
NewDeviceUpdateMessage constructs device update message.
type DiscoveryMessage ¶
type DiscoveryMessage struct { MessageWithType NodeID string `json:"n"` Properties map[string]string `json:"p"` IsFirstStart bool `json:"f"` MaxDevices int `json:"m"` }
DiscoveryMessage used by worker for periodic server pings.
func NewDiscoveryMessage ¶
func NewDiscoveryMessage(nodeID string, firstStart bool, properties map[string]string, maxDevices int) *DiscoveryMessage
NewDiscoveryMessage constructs discovery message.
type EntityLoadStatusMessage ¶
type EntityLoadStatusMessage struct { MessageWithType NodeID string `json:"n"` Name string `json:"m"` IsSuccess bool `json:"s"` }
EntityLoadStatusMessage used by worker to notify master about entity load status.
func NewEntityLoadStatusMessage ¶
func NewEntityLoadStatusMessage(entityName string, nodeID string, isSuccess bool) *EntityLoadStatusMessage
NewEntityLoadStatusMessage constructs entity load message.
type ErrCorruptedMessage ¶
type ErrCorruptedMessage struct { }
ErrCorruptedMessage defines a corrupted message error.
func (*ErrCorruptedMessage) Error ¶
func (*ErrCorruptedMessage) Error() string
Error formats output.
type ErrUnknownType ¶
type ErrUnknownType struct { }
ErrUnknownType defines an unknown message type error.
type IMasterMessageParserProvider ¶
type IMasterMessageParserProvider interface { IMessageParserProvider GetDiscoveryMessageChan() chan *DiscoveryMessage GetDeviceUpdateMessageChan() chan *DeviceUpdateMessage GetEntityLoadStatueMessageChan() chan *EntityLoadStatusMessage }
IMasterMessageParserProvider describes messages parser for server.
func NewMasterMessageParser ¶
func NewMasterMessageParser(logger common.ILoggerProvider) IMasterMessageParserProvider
NewMasterMessageParser constructs parser for server.
type IMessageParserProvider ¶
type IMessageParserProvider interface {
ProcessIncomingMessage(r *bus.RawMessage)
}
IMessageParserProvider describes messages parser.
type IWorkerMessageParserProvider ¶
type IWorkerMessageParserProvider interface { IMessageParserProvider GetDeviceAssignmentMessageChan() chan *DeviceAssignmentMessage GetDeviceCommandMessageChan() chan *DeviceCommandMessage }
IWorkerMessageParserProvider describes messages parser for worker.
func NewWorkerMessageParser ¶
func NewWorkerMessageParser(logger common.ILoggerProvider) IWorkerMessageParserProvider
NewWorkerMessageParser constructs parser for worker.
type MessageWithType ¶
type MessageWithType struct { Type bus.MessageType `json:"mt"` SendTime int64 `json:"st"` }
MessageWithType helper type for initial service bus message parsing.