devices

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 15 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 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) GetDevice

func (this *CachedRepository) GetDevice(ctx context.Context, token Token, id string) (models.Device, 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

func (this *CachedRepository) GetProtocol(ctx context.Context, token Token, id string) (models.Protocol, error)

func (*CachedRepository) GetService

func (this *CachedRepository) GetService(ctx context.Context, token Token, device models.Device, id string) (models.Service, error)

GetService reads the service from the device type of the device, which is cached.

func (*CachedRepository) GetToken

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

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

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.

func NewHubs added in v0.16.0

func NewHubs(repositoryUrl string) *Hubs

func (*Hubs) HubOwner added in v0.16.0

func (this *Hubs) HubOwner(ctx context.Context, token string, id string) (string, error)

HubOwner returns owner_id of the hub, read with the token; an unknown hub is not found.

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

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