Documentation
¶
Index ¶
- func NewDefinitionID(namespace string, name string, version string) model.DefinitionID
- func NewDefinitionIDFromString(full string) model.DefinitionID
- func NewFeature(name string, opts ...FeatureOpt) model.Feature
- func NewHeaders(opts ...HeaderOpt) protocol.Headers
- func NewNamespacedID(namespace string, name string) model.NamespacedID
- func NewNamespacedIDFromString(full string) model.NamespacedID
- func NewThing(opts ...ThingOpt) model.Thing
- type Client
- func (client *Client) Connect() error
- func (client *Client) Create(id model.NamespacedID, thing model.Thing) error
- func (client *Client) Disconnect()
- func (client *Client) Get(id model.NamespacedID) model.Thing
- func (client *Client) GetThingsRegistryChangedHandler() handlers.ThingsRegistryChangedHandler
- func (client *Client) Remove(id model.NamespacedID) error
- func (client *Client) SetThingsRegistryChangedHandler(handler handlers.ThingsRegistryChangedHandler)
- func (client *Client) Update(id model.NamespacedID) error
- type Configuration
- func (cfg *Configuration) AcknowledgeTimeout() time.Duration
- func (cfg *Configuration) Broker() string
- func (cfg *Configuration) ClientPassword() string
- func (cfg *Configuration) ClientUsername() string
- func (cfg *Configuration) ConnectTimeout() time.Duration
- func (cfg *Configuration) DeviceAuthID() string
- func (cfg *Configuration) DeviceName() string
- func (cfg *Configuration) DevicePassword() string
- func (cfg *Configuration) DeviceTenantID() string
- func (cfg *Configuration) DisconnectTimeout() time.Duration
- func (cfg *Configuration) GatewayDeviceID() string
- func (cfg *Configuration) InitHook() InitializedHook
- func (cfg *Configuration) KeepAlive() time.Duration
- func (cfg *Configuration) RegistryChangedHandler() handlers.ThingsRegistryChangedHandler
- func (cfg *Configuration) SubscribeTimeout() time.Duration
- func (cfg *Configuration) TLSConfig() (rootCA, clientCert, clientKey string)
- func (cfg *Configuration) UnsubscribeTimeout() time.Duration
- func (cfg *Configuration) WithAcknowledgeTimeout(acknowledgeTimeout time.Duration) *Configuration
- func (cfg *Configuration) WithBroker(broker string) *Configuration
- func (cfg *Configuration) WithClientPassword(password string) *Configuration
- func (cfg *Configuration) WithClientUsername(username string) *Configuration
- func (cfg *Configuration) WithConnectTimeout(connectTimeout time.Duration) *Configuration
- func (cfg *Configuration) WithDeviceAuthID(deviceAuthID string) *Configuration
- func (cfg *Configuration) WithDeviceName(name string) *Configuration
- func (cfg *Configuration) WithDevicePassword(devicePassword string) *Configuration
- func (cfg *Configuration) WithDeviceTenantID(deviceTenantID string) *Configuration
- func (cfg *Configuration) WithDisconnectTimeout(disconnectTimeout time.Duration) *Configuration
- func (cfg *Configuration) WithGatewayDeviceID(deviceID string) *Configuration
- func (cfg *Configuration) WithInitHook(hook InitializedHook) *Configuration
- func (cfg *Configuration) WithKeepAlive(keepAlive time.Duration) *Configuration
- func (cfg *Configuration) WithSubscribeTimeout(subscribeTimeout time.Duration) *Configuration
- func (cfg *Configuration) WithTLSConfig(rootCA, clientCert, clientKey string) *Configuration
- func (cfg *Configuration) WithThingsRegistryChangedHandler(handler handlers.ThingsRegistryChangedHandler) *Configuration
- func (cfg *Configuration) WithUnsubscribeTimeout(unsubscribeTimeout time.Duration) *Configuration
- type Device
- type DeviceConnection
- type DeviceCredentials
- type DeviceOpt
- type FeatureOpt
- func WithFeatureDefinition(definitions ...model.DefinitionID) FeatureOpt
- func WithFeatureDefinitionChangedHandler(handler handlers.FeatureDefinitionChangedHandler) FeatureOpt
- func WithFeatureDefinitionFromString(definitions ...string) FeatureOpt
- func WithFeatureOperationsHandler(handler handlers.FeatureOperationsHandler) FeatureOpt
- func WithFeatureProperties(properties map[string]interface{}) FeatureOpt
- func WithFeatureProperty(id string, value interface{}) FeatureOpt
- func WithFeaturePropertyChangedHandler(handler handlers.FeaturePropertyChangedHandler) FeatureOpt
- type HeaderOpt
- type InitializedHook
- type ThingError
- type ThingOpt
- func WithThingAttribute(id string, value interface{}) ThingOpt
- func WithThingAttributeChangedHandler(handler handlers.ThingAttributeChangedHandler) ThingOpt
- func WithThingAttributes(attrs map[string]interface{}) ThingOpt
- func WithThingDefinition(namespace string, name string, version string) ThingOpt
- func WithThingDefinitionChangedHandler(handler handlers.ThingDefinitionChangedHandler) ThingOpt
- func WithThingFeature(id string, value model.Feature) ThingOpt
- func WithThingFeatureChangedHandler(handler handlers.ThingFeatureChangedHandler) ThingOpt
- func WithThingFeatureFrom(id string, featureOpts ...FeatureOpt) ThingOpt
- func WithThingFeatures(features map[string]model.Feature) ThingOpt
- func WithThingID(namespace string, name string) ThingOpt
- func WithThingOperationsHandler(handler handlers.ThingOperationsHandler) ThingOpt
- func WithThingPolicy(namespace string, name string) ThingOpt
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 ¶
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
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) 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
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 ¶
DeviceCredentials represents the device authentication ID and device password
type DeviceOpt ¶
type DeviceOpt func(devOpt *devOpts) error
DeviceOpt represents a device options
func WithDeviceCredentials ¶
WithDeviceCredentials sets a device option credentials
func WithDeviceTenantID ¶
WithDeviceTenantID sets a device option tenant ID
func WithViaGateway ¶
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 ¶
WithContentType sets a header value for content type
func WithCorrelationID ¶
WithCorrelationID sets a header value for correlation id
func WithReplyTo ¶
WithReplyTo sets a header value for reply to
func WithResponseRequired ¶
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 ¶
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 ¶
WithThingAttributes sets all attributes to the thing's attributes
func WithThingDefinition ¶
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 ¶
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 ¶
WithThingFeatures sets all features to the thing's features
func WithThingID ¶
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 ¶
WithThingPolicy sets the provided namespace and name to the thing's policy ID
Source Files
¶
- client.go
- client_config.go
- client_handler_commands.go
- client_handler_errors.go
- client_handler_events.go
- client_handler_utils.go
- client_init.go
- client_internal.go
- client_local_config.go
- definition_id.go
- device.go
- device_connection.go
- device_credentials.go
- device_init.go
- feature.go
- feature_init.go
- feature_internal.go
- generator.go
- headers.go
- headers_init.go
- json_util.go
- namespaced_id.go
- thing.go
- thing_errors.go
- thing_init.go
- thing_internal.go
- util.go