devices

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package devices holds what device commands and device events share about services.

Index

Constants

View Source
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

func ContentsMatch(contents []models.Content, functionId string, aspects []models.AspectNode) bool

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

func ServiceIdToTopic(id string) string

ServiceIdToTopic is the Kafka topic of the data of a service.

func SplitModifier

func SplitModifier(id string) (pureId string, modifier map[string][]string)

SplitModifier returns the id without modifier and the modifier parameters; parameters that cannot be read are ignored.

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) GetDevice

func (this *CachedRepository) GetDevice(token Token, id string) (models.Device, 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 (this *CachedRepository) GetProtocol(token Token, id string) (models.Protocol, error)

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.

func (*CachedRepository) GetToken

func (this *CachedRepository) GetToken(user string) (Token, error)

GetToken is the token of the user, e.g. by token exchange.

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).

type Token

type Token string

Token is a user token including the "Bearer " prefix.

func (Token) GetJSON

func (this Token) GetJSON(resourceUrl string, result any) error

GetJSON reads a resource of another platform service with the token; an answer other than 2xx is an error with status and body.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL