Documentation ¶
Index ¶
- func CmdLogFields(cmd *protocol.Envelope) watermill.LogFields
- func EventPublishTopic(deviceID string, topic *protocol.Topic) string
- func NewFeatureNotFoundError(cmdEnvelope *protocol.Envelope, thingID string, featureID string) *protocol.Envelope
- func NewFeaturesNotFoundError(cmdEnvelope *protocol.Envelope, thingID string) *protocol.Envelope
- func NewIDInvalidError(cmdEnvelope *protocol.Envelope, thingID string) *protocol.Envelope
- func NewIDNotSettableError(cmdEnvelope *protocol.Envelope) *protocol.Envelope
- func NewInvalidFieldSelectorError(cmdEnvelope *protocol.Envelope, jsonError error) *protocol.Envelope
- func NewInvalidJSONValueError(cmdEnvelope *protocol.Envelope, jsonError error) *protocol.Envelope
- func NewPropertiesNotFoundError(cmdEnvelope *protocol.Envelope, thingID string, featureID string, desired bool) *protocol.Envelope
- func NewPropertyNotFoundError(cmdEnvelope *protocol.Envelope, thingID string, featureID string, ...) *protocol.Envelope
- func NewThingConflictError(cmdEnvelope *protocol.Envelope, thingID string) *protocol.Envelope
- func NewThingNotFoundError(cmdEnvelope *protocol.Envelope, thingID string) *protocol.Envelope
- func NewUnknownError(cmdEnvelope *protocol.Envelope, msg string, error error) *protocol.Envelope
- func PublishHonoMsg(msg *message.Message, publisher message.Publisher, dInfo DeviceInfo, ...) error
- func ResponseEnvelopeWithValue(cmdEnvelope *protocol.Envelope, status int, value interface{}) *protocol.Envelope
- func ResponsePublishTopic(deviceID string, envTopic *protocol.Topic) string
- func TopicNamespaceID(topic *protocol.Topic) string
- type Command
- type CommandFunc
- type CommandOutput
- type DeviceInfo
- type Handler
- type Scope
- type ThingError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CmdLogFields ¶
CmdLogFields builds a command log data.
func EventPublishTopic ¶
EventPublishTopic builds the message topic from the provided event envelope topic.
func NewFeatureNotFoundError ¶
func NewFeatureNotFoundError(cmdEnvelope *protocol.Envelope, thingID string, featureID string) *protocol.Envelope
NewFeatureNotFoundError creates feature not found error.
func NewFeaturesNotFoundError ¶
NewFeaturesNotFoundError creates features not found error.
func NewIDInvalidError ¶
NewIDInvalidError creates invalid Thing ID error.
func NewIDNotSettableError ¶
NewIDNotSettableError creates Thing ID not settable error.
func NewInvalidFieldSelectorError ¶
func NewInvalidFieldSelectorError(cmdEnvelope *protocol.Envelope, jsonError error) *protocol.Envelope
NewInvalidFieldSelectorError creates invalid json field selector error.
func NewInvalidJSONValueError ¶
NewInvalidJSONValueError creates invalid json format error.
func NewPropertiesNotFoundError ¶
func NewPropertiesNotFoundError( cmdEnvelope *protocol.Envelope, thingID string, featureID string, desired bool, ) *protocol.Envelope
NewPropertiesNotFoundError creates properties not found error.
func NewPropertyNotFoundError ¶
func NewPropertyNotFoundError( cmdEnvelope *protocol.Envelope, thingID string, featureID string, pointer string, desired bool, ) *protocol.Envelope
NewPropertyNotFoundError creates property not found error.
func NewThingConflictError ¶
NewThingConflictError creates thing conflict error.
func NewThingNotFoundError ¶
NewThingNotFoundError creates thing not found error.
func NewUnknownError ¶
NewUnknownError creates ThingError for unexpected error.
func PublishHonoMsg ¶
func PublishHonoMsg(msg *message.Message, publisher message.Publisher, dInfo DeviceInfo, thingID string) error
PublishHonoMsg publishes the message with device to cloud messaging topic.
func ResponseEnvelopeWithValue ¶
func ResponseEnvelopeWithValue( cmdEnvelope *protocol.Envelope, status int, value interface{}, ) *protocol.Envelope
ResponseEnvelopeWithValue builds a response envelope.
func ResponsePublishTopic ¶
ResponsePublishTopic builds the message topic from the provided response envelope topic.
func TopicNamespaceID ¶
TopicNamespaceID returns the namespace defined by the provided topic.
Types ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command contains the parsed command data used by CommandFunc to perform the ditto command.
The thingID is parsed from the envelop topic. The target and the additional path (if any) are get form the envelope path, e.g. "sensor" as target and "temperature/value" as internal path if the envelope path is "/features/sensor/properties/temperature/value".
type CommandFunc ¶
type CommandFunc func(h *Handler, cmd *Command, out *CommandOutput)
CommandFunc performs the passed Command using the provided Handler. Generates the command output, i.e. the response if required and the event to be published if the command is executed successfully.
type CommandOutput ¶
type CommandOutput struct {
// contains filtered or unexported fields
}
CommandOutput contains response and event which must be published or invalid value error. In addition it could contain the thing/feature local revision that could be marked as synchronized if the command is successfully forwarded to the cloud.
type DeviceInfo ¶
DeviceInfo contains the gateway device details.
type Handler ¶
type Handler struct { DeviceInfo MosquittoPub message.Publisher HonoPub message.Publisher Storage persistence.ThingsStorage Logger logger.Logger }
Handler manages ditto protocol commands using the local digital twins storage.
func (*Handler) HandleCommand ¶
HandleCommand executes ditto protocol command using the local digital twins storage.
func (*Handler) LoadFeature ¶
func (h *Handler) LoadFeature( thingID string, featureID string, envelope *protocol.Envelope, ) (*model.Feature, error)
LoadFeature loads the feature from the given thing if present. If there is no such thing and auto-provisioning is enabled the thing is created, persisted and a thing created event is published. Then tries to load the feature from the created thing. Returns error if the thing is not presenting and auto-provisioning is disabled or there is no such feature.
type Scope ¶
type Scope int
Scope type is used to define the command target resource type.
const ( ScopeUnknown Scope = iota ScopeThing ScopeAttributes // unsupported ScopeDefinition // unsupported ScopePolicy // unsupported ScopeFeatures ScopeFeature ScopeFeatureProperties ScopeFeatureProperty ScopeFeatureDesiredProperties ScopeFeatureDesiredProperty ScopeFeatureDefinition // unsupported )
Scope types.
func ParseCmdPath ¶
ParseCmdPath parses a ditto protocol path finding the type and name of the thing referenced resource returning the command SCOPE, id and additional path, e.g. ScopeFeatureProperties as scope, "sensor" as id and "temperature/value" as internal path if the command path is "/features/sensor/properties/temperature/value".