Documentation
¶
Overview ¶
Package devices holds what device commands and device events share about services.
Index ¶
- Constants
- func ContentsMatch(contents []models.Content, functionId string, aspects []models.AspectNode) bool
- func ServiceIdToTopic(id string) string
- func SplitModifier(id string) (pureId string, modifier map[string][]string)
- type AspectNodes
- type CachedRepository
- func (this *CachedRepository) GetDevice(token Token, id string) (models.Device, error)
- func (this *CachedRepository) GetDeviceGroup(token Token, id string) (models.DeviceGroup, error)
- func (this *CachedRepository) GetDeviceType(token Token, id string) (models.DeviceType, error)
- func (this *CachedRepository) GetProtocol(token Token, id string) (models.Protocol, error)
- func (this *CachedRepository) GetService(token Token, device models.Device, id string) (models.Service, error)
- func (this *CachedRepository) GetToken(user string) (Token, error)
- type Hubs
- type Repository
- type Token
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 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 ServiceIdToTopic ¶
ServiceIdToTopic is the Kafka topic of the data of a service.
Types ¶
type AspectNodes ¶
type AspectNodes struct {
// contains filtered or unexported fields
}
AspectNodes resolves aspect node ids to full nodes, which the marshaller needs to match paths; process-deployment did this at deploy time. Nodes change rarely and are cached.
func NewAspectNodes ¶
func NewAspectNodes(repoUrl string) *AspectNodes
func NewAspectNodesWith ¶
func NewAspectNodesWith(fetch func(token Token, id string) (models.AspectNode, error)) *AspectNodes
NewAspectNodesWith uses fetch to load nodes, e.g. in tests.
func (*AspectNodes) Resolve ¶
func (this *AspectNodes) Resolve(token Token, nodes []models.AspectNode) ([]models.AspectNode, error)
resolve completes nodes that carry only their id, e.g. the aspects of a modeled payload
func (*AspectNodes) ResolveIds ¶
func (this *AspectNodes) ResolveIds(token Token, ids []string) ([]models.AspectNode, error)
type CachedRepository ¶
type CachedRepository struct {
// contains filtered or unexported fields
}
CachedRepository caches the answers of device-repository; the cache invalidation signals of service-commons clear the entries of changed resources.
func NewRepository ¶
func NewRepository(repositoryUrl string, tokens auth.UserTokenSource, cacheTimeout time.Duration) (*CachedRepository, error)
func (*CachedRepository) GetDeviceGroup ¶
func (this *CachedRepository) GetDeviceGroup(token Token, id string) (models.DeviceGroup, error)
func (*CachedRepository) GetDeviceType ¶
func (this *CachedRepository) GetDeviceType(token Token, id string) (models.DeviceType, error)
func (*CachedRepository) GetProtocol ¶
func (*CachedRepository) GetService ¶
func (this *CachedRepository) GetService(token Token, device models.Device, id string) (models.Service, error)
GetService reads a service from the cache or from the device type of the device.
type Hubs ¶ added in v0.16.0
type Hubs struct {
// contains filtered or unexported fields
}
Hubs reads the owners of hubs from device-repository; deployments and instances of a gateway belong to the owner of its hub (FOG-11).
type Repository ¶
type Repository interface {
GetDevice(token Token, id string) (models.Device, error)
GetService(token Token, device models.Device, serviceId string) (models.Service, error)
GetProtocol(token Token, id string) (models.Protocol, error)
GetToken(user string) (Token, error)
GetDeviceType(token Token, id string) (models.DeviceType, error)
GetDeviceGroup(token Token, id string) (models.DeviceGroup, error)
}
Repository reads devices, device types, protocols and device groups with the token of a user, as the external-task-worker did (TASK-01).