client

package
v0.1.0-M4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefinitionID

func NewDefinitionID(namespace string, name string, version string) model.DefinitionID

NewDefinitionID creates a new DefinitionId instance with namespace, name and version provided

func NewDefinitionIDFromString

func NewDefinitionIDFromString(full string) model.DefinitionID

NewDefinitionIDFromString creates a new DefinitionId instance from the provided string

func NewFeature

func NewFeature(name string, opts ...FeatureOpt) model.Feature

NewFeature creates a new feture from the provided name and feture options

func NewHeaders

func NewHeaders(opts ...HeaderOpt) protocol.Headers

NewHeaders creates a new protocol header

func NewNamespacedID

func NewNamespacedID(namespace string, name string) model.NamespacedID

NewNamespacedID creates a new NamespacedID instance using the provided namespace and name

func NewNamespacedIDFromString

func NewNamespacedIDFromString(full string) model.NamespacedID

NewNamespacedIDFromString creates a new NamespacedID using the provided string

func NewThing

func NewThing(opts ...ThingOpt) model.Thing

NewThing creates a new thing instance from the provided thing options

Types

type Client

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

Client represetns the MQTT client

func NewClient

func NewClient(cfg *Configuration) *Client

NewClient creates a new client from the provided configuration

func (*Client) Connect

func (client *Client) Connect() error

Connect connects the client

func (*Client) Create

func (client *Client) Create(id model.NamespacedID, thing model.Thing) error

Create creates a thing with the provided namespace ID

func (*Client) Disconnect

func (client *Client) Disconnect()

Disconnect unsubscribes and disconects the client

func (*Client) Get

func (client *Client) Get(id model.NamespacedID) model.Thing

Get returns a things by provided namespace ID

func (*Client) GetThingsRegistryChangedHandler

func (client *Client) GetThingsRegistryChangedHandler() handlers.ThingsRegistryChangedHandler

GetThingsRegistryChangedHandler gets the registry's handler

func (*Client) Remove

func (client *Client) Remove(id model.NamespacedID) error

Remove removes a thing with the provided namespace ID

func (*Client) SetThingsRegistryChangedHandler

func (client *Client) SetThingsRegistryChangedHandler(handler handlers.ThingsRegistryChangedHandler)

SetThingsRegistryChangedHandler sets the registry's handler

func (*Client) Update

func (client *Client) Update(id model.NamespacedID) error

Update modifies a thing with the provided namespace ID

type Configuration

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

Configuration provides the Client's configuration

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration creates a new Configuration instance

func (*Configuration) AcknowledgeTimeout

func (cfg *Configuration) AcknowledgeTimeout() time.Duration

AcknowledgeTimeout provides the currently configured acknowledge timeout

func (*Configuration) Broker

func (cfg *Configuration) Broker() string

Broker provides the current MQTT broker the client is to connect to

func (*Configuration) ClientPassword

func (cfg *Configuration) ClientPassword() string

ClientPassword provides the currently configured password authentication used for the underlying connection

func (*Configuration) ClientUsername

func (cfg *Configuration) ClientUsername() string

ClientUsername provides the currently configured username authentication used for the underlying connection

func (*Configuration) ConnectTimeout

func (cfg *Configuration) ConnectTimeout() time.Duration

ConnectTimeout provides the currently configured connection timeout

func (*Configuration) DeviceAuthID

func (cfg *Configuration) DeviceAuthID() string

DeviceAuthID provides the currently configured device authentication ID

func (*Configuration) DeviceName

func (cfg *Configuration) DeviceName() string

DeviceName provides the currently configured device name

func (*Configuration) DevicePassword

func (cfg *Configuration) DevicePassword() string

DevicePassword provides the currently configured device password

func (*Configuration) DeviceTenantID

func (cfg *Configuration) DeviceTenantID() string

DeviceTenantID provides the currently configured device tenant ID

func (*Configuration) DisconnectTimeout

func (cfg *Configuration) DisconnectTimeout() time.Duration

DisconnectTimeout provides the timeout for disconnecting the client

func (*Configuration) GatewayDeviceID

func (cfg *Configuration) GatewayDeviceID() string

GatewayDeviceID provides the currently configured gateway device ID

func (*Configuration) InitHook

func (cfg *Configuration) InitHook() InitializedHook

InitHook provides the currently configured initialized notification

func (*Configuration) KeepAlive

func (cfg *Configuration) KeepAlive() time.Duration

KeepAlive provides the keep alive connection's period

func (*Configuration) RegistryChangedHandler

func (cfg *Configuration) RegistryChangedHandler() handlers.ThingsRegistryChangedHandler

RegistryChangedHandler provides the currently configured things registry changed handler

func (*Configuration) SubscribeTimeout

func (cfg *Configuration) SubscribeTimeout() time.Duration

SubscribeTimeout provides the currently configured subscribe timeout

func (*Configuration) TLSConfig

func (cfg *Configuration) TLSConfig() (rootCA, clientCert, clientKey string)

TLSConfig provides the current TLS configuration

func (*Configuration) UnsubscribeTimeout

func (cfg *Configuration) UnsubscribeTimeout() time.Duration

UnsubscribeTimeout provides the currently configured unsubscribe timeout

func (*Configuration) WithAcknowledgeTimeout

func (cfg *Configuration) WithAcknowledgeTimeout(acknowledgeTimeout time.Duration) *Configuration

WithAcknowledgeTimeout configures acknowledged timeout

func (*Configuration) WithBroker

func (cfg *Configuration) WithBroker(broker string) *Configuration

WithBroker configures the MQTT's broker the Client to connect to

func (*Configuration) WithClientPassword

func (cfg *Configuration) WithClientPassword(password string) *Configuration

WithClientPassword configures the client password

func (*Configuration) WithClientUsername

func (cfg *Configuration) WithClientUsername(username string) *Configuration

WithClientUsername configures the client username

func (*Configuration) WithConnectTimeout

func (cfg *Configuration) WithConnectTimeout(connectTimeout time.Duration) *Configuration

WithConnectTimeout configures the connect timeout

func (*Configuration) WithDeviceAuthID

func (cfg *Configuration) WithDeviceAuthID(deviceAuthID string) *Configuration

WithDeviceAuthID configures the device authentication ID

func (*Configuration) WithDeviceName

func (cfg *Configuration) WithDeviceName(name string) *Configuration

WithDeviceName configures the device name

func (*Configuration) WithDevicePassword

func (cfg *Configuration) WithDevicePassword(devicePassword string) *Configuration

WithDevicePassword configures the device password

func (*Configuration) WithDeviceTenantID

func (cfg *Configuration) WithDeviceTenantID(deviceTenantID string) *Configuration

WithDeviceTenantID configures the device tenant ID

func (*Configuration) WithDisconnectTimeout

func (cfg *Configuration) WithDisconnectTimeout(disconnectTimeout time.Duration) *Configuration

WithDisconnectTimeout configures the timeout for disconnection of the Client

func (*Configuration) WithGatewayDeviceID

func (cfg *Configuration) WithGatewayDeviceID(deviceID string) *Configuration

WithGatewayDeviceID configures the gateway device ID

func (*Configuration) WithInitHook

func (cfg *Configuration) WithInitHook(hook InitializedHook) *Configuration

WithInitHook configures the initialized notification

func (*Configuration) WithKeepAlive

func (cfg *Configuration) WithKeepAlive(keepAlive time.Duration) *Configuration

WithKeepAlive configures the keep alive time period for the underlying Client's connection

func (*Configuration) WithSubscribeTimeout

func (cfg *Configuration) WithSubscribeTimeout(subscribeTimeout time.Duration) *Configuration

WithSubscribeTimeout configures subscribe timeout

func (*Configuration) WithTLSConfig

func (cfg *Configuration) WithTLSConfig(rootCA, clientCert, clientKey string) *Configuration

WithTLSConfig configures the TLS options to the MQTT server/broker

func (*Configuration) WithThingsRegistryChangedHandler

func (cfg *Configuration) WithThingsRegistryChangedHandler(handler handlers.ThingsRegistryChangedHandler) *Configuration

WithThingsRegistryChangedHandler configures the things registry changed handler

func (*Configuration) WithUnsubscribeTimeout

func (cfg *Configuration) WithUnsubscribeTimeout(unsubscribeTimeout time.Duration) *Configuration

WithUnsubscribeTimeout configures unsubscribe timeout

type Device

type Device interface {
	GetID() model.NamespacedID
	GetViaGateway() model.NamespacedID
	GetTenantID() string
	GetCredentials() DeviceCredentials
	GetConnection() DeviceConnection
}

Device provides an ability to gets device data

type DeviceConnection

type DeviceConnection interface {
	SendTelemetry(envelope protocol.Envelope) error
	SendEvent(envelope protocol.Envelope) error
}

DeviceConnection enebles the connection to the device

type DeviceCredentials

type DeviceCredentials interface {
	GetAuthID() string
	GetPassword() string
}

DeviceCredentials represents the device authentication ID and device password

type DeviceOpt

type DeviceOpt func(devOpt *devOpts) error

DeviceOpt represents a device options

func WithDeviceCredentials

func WithDeviceCredentials(authID string, pass string) DeviceOpt

WithDeviceCredentials sets a device option credentials

func WithDeviceID

func WithDeviceID(id string) DeviceOpt

WithDeviceID sets a device option ID

func WithDeviceTenantID

func WithDeviceTenantID(tenantID string) DeviceOpt

WithDeviceTenantID sets a device option tenant ID

func WithViaGateway

func WithViaGateway(id string) DeviceOpt

WithViaGateway sets a device option via gateway

type FeatureOpt

type FeatureOpt func(feature *feature) error

FeatureOpt represents feature options

func WithFeatureDefinition

func WithFeatureDefinition(definitions ...model.DefinitionID) FeatureOpt

WithFeatureDefinition sets the feature definition from the provided definition id

func WithFeatureDefinitionChangedHandler

func WithFeatureDefinitionChangedHandler(handler handlers.FeatureDefinitionChangedHandler) FeatureOpt

WithFeatureDefinitionChangedHandler sets the feature definition changed handler

func WithFeatureDefinitionFromString

func WithFeatureDefinitionFromString(definitions ...string) FeatureOpt

WithFeatureDefinitionFromString sets the feture definition from the provided string

func WithFeatureOperationsHandler

func WithFeatureOperationsHandler(handler handlers.FeatureOperationsHandler) FeatureOpt

WithFeatureOperationsHandler sets the feature operations handler

func WithFeatureProperties

func WithFeatureProperties(properties map[string]interface{}) FeatureOpt

WithFeatureProperties sets the feature properties from the provided properties

func WithFeatureProperty

func WithFeatureProperty(id string, value interface{}) FeatureOpt

WithFeatureProperty sets the feture property from the provided property id and property

func WithFeaturePropertyChangedHandler

func WithFeaturePropertyChangedHandler(handler handlers.FeaturePropertyChangedHandler) FeatureOpt

WithFeaturePropertyChangedHandler sets the feature property changed handler

type HeaderOpt

type HeaderOpt func(hdrs *headers) error

HeaderOpt represents header options

func WithContentType

func WithContentType(contentType string) HeaderOpt

WithContentType sets a header value for content type

func WithCorrelationID

func WithCorrelationID(correlationID string) HeaderOpt

WithCorrelationID sets a header value for correlation id

func WithReplyTo

func WithReplyTo(replyTo string) HeaderOpt

WithReplyTo sets a header value for reply to

func WithResponseRequired

func WithResponseRequired(isResponseRequired bool) HeaderOpt

WithResponseRequired sets a header value for response required

type InitializedHook

type InitializedHook func(client *Client, configuration *Configuration, err error)

InitializedHook is used for initialized notification

type ThingError

type ThingError struct {
	ErrorCode dittoError `json:"error"`
	Status    int        `json:"status"`
	Message   string     `json:"message"`
}

ThingError represents the thing error

func NewMessagesInternalError

func NewMessagesInternalError(messageFormat string, args ...interface{}) *ThingError

NewMessagesInternalError creates a new thing error for an internal error

func NewMessagesParameterInvalidError

func NewMessagesParameterInvalidError(messageFormat string, args ...interface{}) *ThingError

NewMessagesParameterInvalidError creates a new thing error message for an invalid parameter

func NewMessagesSubjectNotFound

func NewMessagesSubjectNotFound(messageFormat string, args ...interface{}) *ThingError

NewMessagesSubjectNotFound creates a new thing error message for a subject not found

func (*ThingError) Error

func (thErr *ThingError) Error() string

type ThingOpt

type ThingOpt func(thing *thing) error

ThingOpt represents thing options

func WithThingAttribute

func WithThingAttribute(id string, value interface{}) ThingOpt

WithThingAttribute sets/adds an attribute to the thing's attributes

func WithThingAttributeChangedHandler

func WithThingAttributeChangedHandler(handler handlers.ThingAttributeChangedHandler) ThingOpt

WithThingAttributeChangedHandler sets an attribute changed handler to the thing's attribute changed handlers

func WithThingAttributes

func WithThingAttributes(attrs map[string]interface{}) ThingOpt

WithThingAttributes sets all attributes to the thing's attributes

func WithThingDefinition

func WithThingDefinition(namespace string, name string, version string) ThingOpt

WithThingDefinition sets the provided namespace, name and version to the thing's definition

func WithThingDefinitionChangedHandler

func WithThingDefinitionChangedHandler(handler handlers.ThingDefinitionChangedHandler) ThingOpt

WithThingDefinitionChangedHandler sets a definition changed handler to the thing's definition changed handler

func WithThingFeature

func WithThingFeature(id string, value model.Feature) ThingOpt

WithThingFeature sets/adds a feature from the provided Feature to the thing's features

func WithThingFeatureChangedHandler

func WithThingFeatureChangedHandler(handler handlers.ThingFeatureChangedHandler) ThingOpt

WithThingFeatureChangedHandler sets a feature changed handler to the thing's feature changed handler

func WithThingFeatureFrom

func WithThingFeatureFrom(id string, featureOpts ...FeatureOpt) ThingOpt

WithThingFeatureFrom sets/adds a feature from the provided Feature options to the thing's features

func WithThingFeatures

func WithThingFeatures(features map[string]model.Feature) ThingOpt

WithThingFeatures sets all features to the thing's features

func WithThingID

func WithThingID(namespace string, name string) ThingOpt

WithThingID sets the provided namespace and name to the thing's ID

func WithThingOperationsHandler

func WithThingOperationsHandler(handler handlers.ThingOperationsHandler) ThingOpt

WithThingOperationsHandler sets an operations handler to the thing's operations handler

func WithThingPolicy

func WithThingPolicy(namespace string, name string) ThingOpt

WithThingPolicy sets the provided namespace and name to the thing's policy ID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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