observation

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsResourceObservableWithInterface

func IsResourceObservableWithInterface(ctx context.Context, coapConn ClientConn, resourceHref, resourceType, observeInterface string) (bool, error)

Query /oic/res resource to determine whether resource with given href is observable and supports given interface.

func NewObservedResource

func NewObservedResource(href, resInterface string) *observedResource

Types

type ClientConn added in v2.2.4

type ClientConn interface {
	Get(ctx context.Context, path string, opts ...message.Option) (*pool.Message, error)
	Observe(ctx context.Context, path string, observeFunc func(req *pool.Message), opts ...message.Option) (*tcp.Observation, error)
	ReleaseMessage(m *pool.Message)
}

type DeviceObserver

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

DeviceObserver is a type that sets up resources observation for a single device.

func NewDeviceObserver

func NewDeviceObserver(ctx context.Context, deviceID string, coapConn ClientConn, rdClient GrpcGatewayClient, callbacks ResourcesObserverCallbacks, opts ...Option) (*DeviceObserver, error)

Create new deviceObserver with given settings

func (*DeviceObserver) AddPublishedResources

func (d *DeviceObserver) AddPublishedResources(ctx context.Context, resources []*commands.Resource) error

Add observation of published resources.

Function does nothing if device shadow is disabled or /oic/res observation type (ObservationType_PerDevice) is active. Only if observation per published resource (ObservationType_PerResource) is active does the function try to add the given resources to active observations.

func (*DeviceObserver) Clean

func (d *DeviceObserver) Clean(ctx context.Context)

Remove all observations.

func (*DeviceObserver) GetDeviceID

func (d *DeviceObserver) GetDeviceID() string

func (*DeviceObserver) GetObservationType

func (d *DeviceObserver) GetObservationType() ObservationType

func (*DeviceObserver) GetResources

func (d *DeviceObserver) GetResources() ([]*commands.ResourceId, error)

Get list of observed resources for device.

func (*DeviceObserver) GetShadowSynchronization

func (d *DeviceObserver) GetShadowSynchronization() commands.ShadowSynchronization

func (*DeviceObserver) RemovePublishedResources

func (d *DeviceObserver) RemovePublishedResources(ctx context.Context, resourceHrefs []string)

Remove observation of published resources.

Function does nothing if device shadow is disabled or /oic/res observation type (ObservationType_PerDevice) is active. Only if observation per published resource (ObservationType_PerResource) is active does the function try to cancel the observations of given resources.

type DeviceObserverConfig

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

type GrpcGatewayClient added in v2.2.4

type GrpcGatewayClient interface {
	GetDevicesMetadata(ctx context.Context, in *pb.GetDevicesMetadataRequest, opts ...grpc.CallOption) (pb.GrpcGateway_GetDevicesMetadataClient, error)
	GetResourceLinks(ctx context.Context, in *pb.GetResourceLinksRequest, opts ...grpc.CallOption) (pb.GrpcGateway_GetResourceLinksClient, error)
}

type LoggerOpt added in v2.2.4

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

Set logger option

func WithLogger added in v2.2.4

func WithLogger(logger log.Logger) LoggerOpt

func (LoggerOpt) Apply added in v2.2.4

func (o LoggerOpt) Apply(opts *DeviceObserverConfig)

type ObservationType

type ObservationType int
const (
	ObservationType_Detect      ObservationType = 0 // default, detect if /oic/res is observable using GET method, if not fallback to per resource observations
	ObservationType_PerDevice   ObservationType = 1 // single /oic/res observation
	ObservationType_PerResource ObservationType = 2 // fallback, observation of every published resource
)

type ObservationTypeOpt

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

Force observationType

func WithObservationType

func WithObservationType(observationType ObservationType) ObservationTypeOpt

func (ObservationTypeOpt) Apply

type OnGetResourceContent

type OnGetResourceContent = func(ctx context.Context, deviceID, resourceHref string, notification *pool.Message) error

type OnObserveResource

type OnObserveResource = func(ctx context.Context, deviceID, resourceHref string, batch bool, notification *pool.Message) error

type Option

type Option interface {
	Apply(o *DeviceObserverConfig)
}

type ResourcesObserverCallbacks

type ResourcesObserverCallbacks struct {
	OnObserveResource    OnObserveResource
	OnGetResourceContent OnGetResourceContent
}

func MakeResourcesObserverCallbacks

func MakeResourcesObserverCallbacks(OnObserveResource OnObserveResource, OnGetResourceContent OnGetResourceContent) ResourcesObserverCallbacks

type ShadowSynchronizationOpt

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

Force shadowSynchronization value

func WithShadowSynchronization

func WithShadowSynchronization(shadowSynchronization commands.ShadowSynchronization) ShadowSynchronizationOpt

func (ShadowSynchronizationOpt) Apply

Jump to

Keyboard shortcuts

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