Documentation
¶
Index ¶
Constants ¶
const ( // Constants for configuration properties provided via the MessageBusConfig's Optional field. Username = "Username" Password = "Password" ClientId = "ClientId" Topic = "Topic" Qos = "Qos" KeepAlive = "KeepAlive" Retained = "Retained" ConnectionPayload = "ConnectionPayload" )
const ( // Different Client operations. PublishOperation = "Publish" SubscribeOperation = "Subscribe" ConnectOperation = "Connect" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client facilitates communication to an MQTT server and provides functionality needed to send and receive MQTT messages.
func NewMQTTClient ¶
func NewMQTTClient(options types.MessageBusConfig) (Client, error)
NewMQTTClient constructs a new MQTT client based on the options provided.
func NewMQTTClientWithCreator ¶
func NewMQTTClientWithCreator(options types.MessageBusConfig, marshaler MessageMarshaler, unmarshaler MessageUnmarshaler, creator ClientCreator) (Client, error)
NewMQTTClientWithCreator constructs a new MQTT client based on the options and ClientCreator provided.
func (Client) Connect ¶
Connect establishes a connection to a MQTT server. This must be called before any other functionality provided by the Client.
func (Client) Disconnect ¶
Disconnect closes the connection to the connected MQTT server.
type ClientCreator ¶
type ClientCreator func(config types.MessageBusConfig) (mqtt.Client, error)
ClientCreator defines the function signature for creating an MQTT client.
func DefaultClientCreator ¶
func DefaultClientCreator() ClientCreator
DefaultClientCreator returns a default function for creating MQTT clients.
type ConnectionOptions ¶
type ConnectionOptions struct {
BrokerURL string
}
ConnectionOptions contains the connection configurations for the MQTT client.
NOTE: The connection properties resides in its own struct in order to avoid the property being loaded in via
reflection during the load process.
type MQTTClientConfig ¶
type MQTTClientConfig struct {
BrokerURL string
MQTTClientOptions
}
MQTTClientConfig contains all the configurations for the MQTT client.
func CreateMQTTClientConfiguration ¶
func CreateMQTTClientConfiguration(messageBusConfig types.MessageBusConfig) (MQTTClientConfig, error)
CreateMQTTClientConfiguration constructs a MQTTClientConfig based on the provided MessageBusConfig.
type MQTTClientOptions ¶
type MQTTClientOptions struct {
Username string
Password string
ClientId string
Topic string
Qos int
KeepAlive int
Retained bool
ConnectionPayload string
}
MQTTClientOptions contains the client options which are loaded via reflection
func CreateMQTTClientOptionsWithDefaults ¶
func CreateMQTTClientOptionsWithDefaults() MQTTClientOptions
type MessageMarshaler ¶
MessageMarshaler defines the function signature for marshaling structs into []byte.
type MessageUnmarshaler ¶
MessageUnmarshaler defines the function signature for unmarshaling []byte into structs.
type OperationErr ¶
type OperationErr struct {
// contains filtered or unexported fields
}
OperationErr defines an error representing operations which have failed.
func NewOperationErr ¶
func NewOperationErr(operation string, message string) OperationErr
NewOperationErr creates a new OperationErr
func (OperationErr) Error ¶
func (oe OperationErr) Error() string
type TimeoutErr ¶
type TimeoutErr struct {
// contains filtered or unexported fields
}
TimeoutErr defines an error representing operations which have not completed and surpassed the allowed wait time.
func NewTimeoutError ¶
func NewTimeoutError(operation string, message string) TimeoutErr
NewTimeoutError creates a new TimeoutErr.
func (TimeoutErr) Error ¶
func (te TimeoutErr) Error() string