Documentation ¶
Index ¶
- func GetResourceLinks(ctx context.Context, coapConn ClientConn, href string) (schema.ResourceLinks, uint64, error)
- func IsDiscoveryResourceObservable(links schema.ResourceLinks) (bool, error)
- 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) GetTwinEnabled() bool
- func (d *DeviceObserver) RemovePublishedResources(ctx context.Context, resourceHrefs []string)
- func (d *DeviceObserver) ResourceHasBeenSynchronized(ctx context.Context, href string)
- type DeviceObserverConfig
- type GrpcGatewayClient
- type LoggerOpt
- type MaxETagsCountInRequestOpt
- type Observation
- type ObservationType
- type ObservationTypeOpt
- type OnGetResourceContent
- type OnObserveResource
- type Option
- type RequireBatchObserveEnabledOpt
- type ResourceAggregateClient
- type ResourcesObserverCallbacks
- type TwinEnabledOpt
- type UpdateTwinSynchronization
- type UseETagsOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetResourceLinks ¶ added in v2.4.1
func GetResourceLinks(ctx context.Context, coapConn ClientConn, href string) (schema.ResourceLinks, uint64, error)
Query resource links from the given resource with the interface oic.if.ll.
func IsDiscoveryResourceObservable ¶ added in v2.4.1
func IsDiscoveryResourceObservable(links schema.ResourceLinks) (bool, error)
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, raClient ResourceAggregateClient, 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 twin 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) GetTwinEnabled ¶ added in v2.6.0
func (d *DeviceObserver) GetTwinEnabled() bool
func (*DeviceObserver) RemovePublishedResources ¶
func (d *DeviceObserver) RemovePublishedResources(ctx context.Context, resourceHrefs []string)
Remove observation of published resources.
Function does nothing if device twin 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.
func (*DeviceObserver) ResourceHasBeenSynchronized ¶ added in v2.6.0
func (d *DeviceObserver) ResourceHasBeenSynchronized(ctx context.Context, href string)
type DeviceObserverConfig ¶
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) GetLatestDeviceETags(ctx context.Context, in *pbRD.GetLatestDeviceETagsRequest, opts ...grpc.CallOption) (*pbRD.GetLatestDeviceETagsResponse, 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 MaxETagsCountInRequestOpt ¶ added in v2.10.0
type MaxETagsCountInRequestOpt struct {
// contains filtered or unexported fields
}
Limit of the number of latest etags acquired from event store.
func WithMaxETagsCountInRequest ¶ added in v2.10.0
func WithMaxETagsCountInRequest(v uint32) MaxETagsCountInRequestOpt
func (MaxETagsCountInRequestOpt) Apply ¶ added in v2.10.0
func (o MaxETagsCountInRequestOpt) Apply(opts *DeviceObserverConfig)
type Observation ¶ added in v2.6.0
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 RequireBatchObserveEnabledOpt ¶ added in v2.6.0
type RequireBatchObserveEnabledOpt struct {
// contains filtered or unexported fields
}
Force observationType
func WithRequireBatchObserveEnabled ¶ added in v2.6.0
func WithRequireBatchObserveEnabled(v bool) RequireBatchObserveEnabledOpt
func (RequireBatchObserveEnabledOpt) Apply ¶ added in v2.6.0
func (o RequireBatchObserveEnabledOpt) Apply(opts *DeviceObserverConfig)
type ResourceAggregateClient ¶ added in v2.4.1
type ResourceAggregateClient interface {
UnpublishResourceLinks(ctx context.Context, in *commands.UnpublishResourceLinksRequest, opts ...grpc.CallOption) (*commands.UnpublishResourceLinksResponse, error)
}
type ResourcesObserverCallbacks ¶
type ResourcesObserverCallbacks struct { OnObserveResource OnObserveResource OnGetResourceContent OnGetResourceContent UpdateTwinSynchronization UpdateTwinSynchronization }
func MakeResourcesObserverCallbacks ¶
func MakeResourcesObserverCallbacks(onObserveResource OnObserveResource, onGetResourceContent OnGetResourceContent, updateTwinSynchronization UpdateTwinSynchronization) ResourcesObserverCallbacks
type TwinEnabledOpt ¶ added in v2.6.0
type TwinEnabledOpt struct {
// contains filtered or unexported fields
}
Force twinEnabled value
func WithTwinEnabled ¶ added in v2.6.1
func WithTwinEnabled(twinEnabled bool) TwinEnabledOpt
func (TwinEnabledOpt) Apply ¶ added in v2.6.0
func (o TwinEnabledOpt) Apply(opts *DeviceObserverConfig)
type UpdateTwinSynchronization ¶ added in v2.6.0
type UseETagsOpt ¶ added in v2.10.0
type UseETagsOpt struct {
// contains filtered or unexported fields
}
Force twinEnabled value
func WithUseETags ¶ added in v2.10.0
func WithUseETags(useETags bool) UseETagsOpt
func (UseETagsOpt) Apply ¶ added in v2.10.0
func (o UseETagsOpt) Apply(opts *DeviceObserverConfig)