2018-03-11 18:06:01 +01:00
|
|
|
package mainflux
|
2017-09-23 01:22:21 +02:00
|
|
|
|
2017-09-29 00:42:45 +02:00
|
|
|
// Message represents a resolved (normalized) raw message.
|
2017-09-23 01:22:21 +02:00
|
|
|
type Message struct {
|
|
|
|
Channel string
|
|
|
|
Publisher string
|
|
|
|
Protocol string
|
|
|
|
Name string `json:"n,omitempty"`
|
|
|
|
Unit string `json:"u,omitempty"`
|
|
|
|
Value float64 `json:"v,omitempty"`
|
|
|
|
StringValue string `json:"vs,omitempty"`
|
|
|
|
BoolValue bool `json:"vb,omitempty"`
|
|
|
|
DataValue string `json:"vd,omitempty"`
|
|
|
|
ValueSum float64 `json:"s,omitempty"`
|
|
|
|
Time float64 `json:"t,omitempty"`
|
|
|
|
UpdateTime float64 `json:"ut,omitempty"`
|
|
|
|
Link string `json:"l,omitempty"`
|
|
|
|
}
|
|
|
|
|
2017-09-29 00:42:45 +02:00
|
|
|
// RawMessage represents a message emitted by the mainflux adapters layer.
|
|
|
|
type RawMessage struct {
|
|
|
|
Channel string `json:"channel"`
|
|
|
|
Publisher string `json:"publisher"`
|
|
|
|
Protocol string `json:"protocol"`
|
|
|
|
ContentType string `json:"content_type"`
|
|
|
|
Payload []byte `json:"payload"`
|
|
|
|
}
|
|
|
|
|
2018-03-11 18:06:01 +01:00
|
|
|
// MessagePublisher specifies a message publishing API.
|
|
|
|
type MessagePublisher interface {
|
|
|
|
// Publishes message to the stream. A non-nil error is returned to indicate
|
2017-09-23 01:22:21 +02:00
|
|
|
// operation failure.
|
2018-03-11 18:06:01 +01:00
|
|
|
Publish(RawMessage) error
|
2017-09-23 01:22:21 +02:00
|
|
|
}
|