observation

package
v2.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDiscoveryResourceObservable added in v2.4.1

func IsDiscoveryResourceObservable(links schema.ResourceLinks) (bool, error)

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) (Observation, error)
	ReleaseMessage(m *pool.Message)
	RemoteAddr() net.Addr
}

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 DeviceObserverConfig struct {
	Logger                     log.Logger
	ObservationType            ObservationType
	TwinEnabled                bool
	TwinEnabledSet             bool
	UseETags                   bool
	RequireBatchObserveEnabled bool
	MaxETagsCountInRequest     uint32
}

type GrpcGatewayClient added in v2.2.4

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

type Observation added in v2.6.0

type Observation = interface {
	Cancel(context.Context, ...message.Option) error
	Canceled() bool
}

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, resourceTypes []string, notification *pool.Message) error

type OnObserveResource

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

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

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 UpdateTwinSynchronization = func(ctx context.Context, deviceID string, status commands.TwinSynchronization_State, t time.Time) error

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)

Jump to

Keyboard shortcuts

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