sync

package
v0.1.0-M4 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: Apache-2.0, EPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoConnection indicates that there is no hub connection.
	ErrNoConnection = errors.New("no hub connection")
)

Functions

This section is empty.

Types

type Synchronizer

type Synchronizer struct {
	DeviceInfo   commands.DeviceInfo
	HonoPub      message.Publisher
	MosquittoPub message.Publisher
	Storage      persistence.ThingsStorage

	Logger logger.Logger
	// contains filtered or unexported fields
}

Synchronizer manages ditto protocol commands using the local digital twins storage.

func (*Synchronizer) Connected

func (s *Synchronizer) Connected(connected bool)

Connected is used to modify the connection state.

func (*Synchronizer) HandleResponse

func (s *Synchronizer) HandleResponse(msg *message.Message) ([]*message.Message, error)

HandleResponse checks and manages retrieve desired properties commands' responses.

func (*Synchronizer) RetrieveDesiredPropertiesCommand

func (s *Synchronizer) RetrieveDesiredPropertiesCommand(thing *model.Thing) *protocol.Envelope

RetrieveDesiredPropertiesCommand returns a command, which can be used to retrieve the provided thing's desired properties from the cloud.

func (*Synchronizer) RetrievedProperties

func (s *Synchronizer) RetrievedProperties(env protocol.Envelope) (map[string]model.Feature, error)

RetrievedProperties extracts features' desired properties from an envelope. Returns error if the content is with unexpected topic, path, status or value.

func (*Synchronizer) Start

func (s *Synchronizer) Start() error

Start is used to trigger a new synchronization process. It will start synchronization for each locally persisted thing.

func (*Synchronizer) Stop

func (s *Synchronizer) Stop()

Stop is used to interrupt a started synchronization process, e.g. on hub connection lost.

func (*Synchronizer) SyncFeature

func (s *Synchronizer) SyncFeature(thingID string, featureID string) error

SyncFeature synchronizes a feature of given thing.

func (*Synchronizer) SyncThings

func (s *Synchronizer) SyncThings(thingIDs ...string) error

SyncThings synchronizes all the things with given IDs.

func (*Synchronizer) UpdateLocalDesiredProperties

func (s *Synchronizer) UpdateLocalDesiredProperties(
	thingID string,
	cloudFeatures map[string]model.Feature,
) error

UpdateLocalDesiredProperties overwrites the locally persisted desired properties with the provided response value.

Jump to

Keyboard shortcuts

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