Documentation
¶
Overview ¶
Package commons holds what several packages share about devices, services and aspects.
Index ¶
- Constants
- func AspectNodesByIds(ctx context.Context, client devicerepository.Interface, ids []string) ([]models.AspectNode, error, int)
- func CompleteAspectNodes(ctx context.Context, client devicerepository.Interface, ...) ([]models.AspectNode, error, int)
- func ContentsMatch(contents []models.Content, functionId string, aspects []models.AspectNode) bool
- func MissingFunctions(contents []models.Content, criteria []FunctionCriteria) (missing []int)
- func ServiceIdToTopic(id string) string
- func SplitModifier(id string) (pureId string, modifier map[string][]string)
- type FunctionCriteria
Constants ¶
const ModifierSeparator = "$"
ModifierSeparator separates the id of a device or device type from the parameters of a modified id, e.g. a device with a local service group: "<id>$<url encoded parameters>".
Variables ¶
This section is empty.
Functions ¶
func AspectNodesByIds ¶
func AspectNodesByIds(ctx context.Context, client devicerepository.Interface, ids []string) ([]models.AspectNode, error, int)
AspectNodesByIds reads the nodes of ids with one request and returns them in the order of ids. Every id has to resolve: device-repository leaves an unknown id out of the list without an error, which is answered here with 404. Nodes are readable for everyone, so no token.
func CompleteAspectNodes ¶
func CompleteAspectNodes(ctx context.Context, client devicerepository.Interface, nodes []models.AspectNode) ([]models.AspectNode, error, int)
CompleteAspectNodes reads the nodes that carry only their id, e.g. the aspects of a modeled payload, with one request; complete nodes stay as they are.
func ContentsMatch ¶
ContentsMatch reports whether a content variable serves the function and every requested aspect, by the aspect itself or a descendant; without aspects the function alone decides. This follows the service filter of external-task-worker v0.1.2 lib/devicegroups.
func MissingFunctions ¶ added in v0.46.0
func MissingFunctions(contents []models.Content, criteria []FunctionCriteria) (missing []int)
MissingFunctions lists the indices of the criteria that no content serves, each checked with ContentsMatch; empty if the contents serve all of them. A device command with additional functions goes to one service that serves every one of them (SNRGY-5157).
func ServiceIdToTopic ¶
ServiceIdToTopic is the Kafka topic of the data of a service.
Types ¶
type FunctionCriteria ¶ added in v0.46.0
type FunctionCriteria struct {
FunctionId string
Aspects []models.AspectNode
}
FunctionCriteria is one function a service has to serve, with every aspect it has to serve it for.