Documentation ¶
Index ¶
- func IsResourceObservableWithInterface(ctx context.Context, coapConn ClientConn, ...) (bool, error)
- func NewObservedResource(href, resInterface string) *observedResource
- type ClientConn
- type DeviceObserver
- func (d *DeviceObserver) AddPublishedResources(ctx context.Context, resources []*commands.Resource) error
- func (d *DeviceObserver) Clean(ctx context.Context)
- func (d *DeviceObserver) GetDeviceID() string
- func (d *DeviceObserver) GetObservationType() ObservationType
- func (d *DeviceObserver) GetResources() ([]*commands.ResourceId, error)
- func (d *DeviceObserver) GetShadowSynchronization() commands.ShadowSynchronization
- func (d *DeviceObserver) RemovePublishedResources(ctx context.Context, resourceHrefs []string)
- type DeviceObserverConfig
- type GrpcGatewayClient
- type LoggerOpt
- type ObservationType
- type ObservationTypeOpt
- type OnGetResourceContent
- type OnObserveResource
- type Option
- type ResourcesObserverCallbacks
- type ShadowSynchronizationOpt
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 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 (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 ¶
func (o ObservationTypeOpt) Apply(opts *DeviceObserverConfig)
type OnGetResourceContent ¶
type OnObserveResource ¶
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 ¶
func (o ShadowSynchronizationOpt) Apply(opts *DeviceObserverConfig)