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(ctx context.Context, token Token, id string) (models.Device, error)
- func (this *CachedRepository) GetDeviceGroup(ctx context.Context, token Token, id string) (models.DeviceGroup, error)
- func (this *CachedRepository) GetDeviceType(ctx context.Context, token Token, id string) (models.DeviceType, error)
- func (this *CachedRepository) GetProtocol(ctx context.Context, token Token, id string) (models.Protocol, error)
- func (this *CachedRepository) GetService(ctx context.Context, 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 by the device-repository client, cleared by the cache invalidation signals.
func NewAspectNodes ¶
func NewAspectNodes(repoUrl string) *AspectNodes
NewAspectNodes reads the nodes without a token, they are readable for everyone
func NewAspectNodesWith ¶
func NewAspectNodesWith(fetch func(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, token Token, ids []string) ([]models.AspectNode, error)
type CachedRepository ¶
type CachedRepository struct {
// contains filtered or unexported fields
}
CachedRepository reads through the device-repository client, which passes on the trace of ctx, and caches per user and request; the cache invalidation signals of service-commons clear what a change of a resource may have made stale.
func NewRepository ¶
func NewRepository(repositoryUrl string, tokens auth.UserTokenSource, cacheTimeout time.Duration) (*CachedRepository, error)
func (*CachedRepository) GetDeviceGroup ¶
func (this *CachedRepository) GetDeviceGroup(ctx context.Context, token Token, id string) (models.DeviceGroup, error)
func (*CachedRepository) GetDeviceType ¶
func (this *CachedRepository) GetDeviceType(ctx context.Context, token Token, id string) (models.DeviceType, error)
func (*CachedRepository) GetProtocol ¶
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). Not cached: a hub may change its owner.
type Repository ¶
type Repository interface {
GetDevice(ctx context.Context, token Token, id string) (models.Device, error)
GetService(ctx context.Context, token Token, device models.Device, serviceId string) (models.Service, error)
GetProtocol(ctx context.Context, token Token, id string) (models.Protocol, error)
GetToken(user string) (Token, error)
GetDeviceType(ctx context.Context, token Token, id string) (models.DeviceType, error)
GetDeviceGroup(ctx context.Context, 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).