connector

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualDeviceDesc

func EqualDeviceDesc(old DeviceDescription, topic DeviceDescription) bool

func EqualTopicDesc

func EqualTopicDesc(old TopicDescription, topic TopicDescription) bool

Types

type Connector

type Connector struct {
	MaxCorrelationIdAge time.Duration
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, config configuration.Config) (result *Connector, err error)

func NewWithFactories

func NewWithFactories(ctx context.Context, config configuration.Config, topicDescProvider TopicDescriptionProvider, mgwFactory MgwFactory, mqttFactory MqttFactory) (result *Connector, err error)

func (*Connector) CommandHandler

func (this *Connector) CommandHandler(deviceId string, serviceId string, command mgw.Command)

func (*Connector) EventHandler

func (this *Connector) EventHandler(topic string, retained bool, payload []byte)

func (*Connector) RefreshDeviceInfo

func (this *Connector) RefreshDeviceInfo()

func (*Connector) ResponseHandler

func (this *Connector) ResponseHandler(topic string, retained bool, payload []byte)

type CorrelationId

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

type DeviceDescription

type DeviceDescription interface {
	GetDeviceName() string
	GetDeviceTypeId() string
	GetLocalDeviceId() string
}

type GenericMgwFactory

type GenericMgwFactory[T MgwClient] func(ctx context.Context, config configuration.Config, refreshNotifier func()) (T, error)

type GenericMqttFactory

type GenericMqttFactory[T MqttClient] func(ctx context.Context, brokerUrl string, clientId string, username string, password string) (T, error)

type GenericTopicDescriptionProvider

type GenericTopicDescriptionProvider[T TopicDescription] func(config configuration.Config, deviceRepo *devicerepo.DeviceRepo) ([]T, error)

type MgwClient

type MgwClient interface {
	ListenToDeviceCommands(deviceId string, commandHandler mgw.DeviceCommandHandler) error
	StopListenToDeviceCommands(deviceId string) error
	SetDevice(deviceId string, name string, deviceTypeid string, state string) error
	RemoveDevice(deviceId string) error
	SendEvent(deviceId string, serviceId string, value []byte) error
	Respond(deviceId string, serviceId string, response mgw.Command) error

	SendClientError(message string)
	SendDeviceError(localDeviceId string, message string)
	SendCommandError(correlationId string, message string)
}

type MgwFactory

type MgwFactory = GenericMgwFactory[MgwClient]

func NewMgwFactory

func NewMgwFactory[MgwClientType MgwClient](f GenericMgwFactory[MgwClientType]) (result MgwFactory)

type MqttClient

type MqttClient interface {
	Subscribe(topic string, qos byte, handler func(topic string, retained bool, payload []byte)) error
	Unsubscribe(topic string) error
	Publish(topic string, qos byte, retained bool, payload []byte) error
}

type MqttFactory

type MqttFactory = GenericMqttFactory[MqttClient]

func NewMqttFactory

func NewMqttFactory[MqttClientType MqttClient](f GenericMqttFactory[MqttClientType]) (result MqttFactory)

type OnlineChecker

type OnlineChecker interface {
	Preprocess(events []TopicDescription) error
	LoadState(desc TopicDescription) (state mgw.State, found bool)
	CheckAndStoreState(desc TopicDescription, retained bool, payload []byte) (state mgw.State, ignore bool)
}

type TopicDescription

type TopicDescription interface {
	DeviceDescription
	GetEventTopic() string
	GetCmdTopic() string
	GetResponseTopic() string
	GetLocalServiceId() string
}

func TopicDescriptionsConverter

func TopicDescriptionsConverter[T TopicDescription](from []T) []TopicDescription

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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