service

package
v2.5.3 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIConfig

type APIConfig struct {
	CoAP CoAPConfig `yaml:"coap"`
}

func (*APIConfig) Validate

func (c *APIConfig) Validate() error

type CoAPConfig

type CoAPConfig struct {
	ID         string `yaml:"id"`
	net.Config `yaml:",inline"`
}

func (*CoAPConfig) Validate

func (c *CoAPConfig) Validate() error

type Config

type Config struct {
	API APIConfig `yaml:"apis"`
}

func (*Config) Validate

func (c *Config) Validate() error

type Device

type Device interface {
	Init()  // start all goroutines for device
	Close() // stop all goroutines for device

	ExportConfig() device.Config // export device config

	GetID() uuid.UUID
	GetLinks(request *net.Request) (links schema.ResourceLinks)
	GetLinksFilteredBy(endpoints schema.Endpoints, deviceIDfilter uuid.UUID, resourceTypesFilter []string, policyBitMaskFitler schema.BitMask) (links schema.ResourceLinks)
	GetName() string
	GetProtocolIndependentID() uuid.UUID
	GetResourceTypes() []string

	HandleRequest(req *net.Request) (*pool.Message, error)

	Range(f func(key string, resource device.Resource) bool)
	AddResources(resources ...device.Resource)
	LoadAndDeleteResource(resourceHref string) (device.Resource, bool)
	CloseAndDeleteResource(resourceHref string) bool
	GetResource(resourceHref string) (device.Resource, bool)

	GetCloudManager() *cloud.Manager
	GetLoop() *eventloop.Loop
	GetThingDescriptionManager() *thingDescription.Manager
}

type NewDeviceFunc

type NewDeviceFunc func(id uuid.UUID, piid uuid.UUID) (Device, error)

type Option

type Option func(*OptionsCfg)

func WithLogger

func WithLogger(logger log.Logger) Option

func WithOnDiscoveryDevices

func WithOnDiscoveryDevices(f func(*net.Request)) Option

type OptionsCfg

type OptionsCfg struct {
	// contains filtered or unexported fields
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config, opts ...Option) (*Service, error)

func (*Service) CopyDevices

func (c *Service) CopyDevices() map[uuid.UUID]Device

func (*Service) CreateDevice

func (c *Service) CreateDevice(id uuid.UUID, newDevice NewDeviceFunc) (Device, error)

func (*Service) DefaultRequestHandler

func (c *Service) DefaultRequestHandler(req *net.Request) (*pool.Message, error)

func (*Service) DeleteAndCloseDevice

func (c *Service) DeleteAndCloseDevice(id uuid.UUID) bool

func (*Service) GetAndDeleteDevice

func (c *Service) GetAndDeleteDevice(id uuid.UUID) (Device, bool)

func (*Service) GetDevice

func (c *Service) GetDevice(id uuid.UUID) (Device, bool)

func (*Service) GetOrCreateDevice

func (c *Service) GetOrCreateDevice(id uuid.UUID, newDevice NewDeviceFunc) (d Device, loaded bool, err error)

func (*Service) Length

func (c *Service) Length() int

func (*Service) LoadDevice

func (c *Service) LoadDevice(di uuid.UUID) (Device, error)

func (*Service) Range

func (c *Service) Range(f func(key uuid.UUID, value Device) bool)

func (*Service) RangeWithLock

func (c *Service) RangeWithLock(f func(key uuid.UUID, value Device) bool)

func (*Service) Serve

func (c *Service) Serve() error

func (*Service) Shutdown

func (c *Service) Shutdown() error

Jump to

Keyboard shortcuts

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