Documentation ¶
Index ¶
Constants ¶
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(config types.MessageBusConfig) (*Client, error)
NewMQTTClient constructs a new MQTT client based on the options provided.
func NewMQTTClientWithCreator ¶
func NewMQTTClientWithCreator( config types.MessageBusConfig, marshaller MessageMarshaller, unmarshaller MessageUnmarshaller, 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, handler pahoMqtt.OnConnectHandler) (pahoMqtt.Client, error)
ClientCreator defines the function signature for creating an MQTT client.
func ClientCreatorWithCertLoader ¶
func ClientCreatorWithCertLoader(certCreator pkg.X509KeyPairCreator, certLoader pkg.X509KeyLoader) ClientCreator
ClientCreatorWithCertLoader creates a ClientCreator which leverages the specified cert creator and loader when 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 { // Client Identifiers Username string Password string ClientId string // Connection information Qos int KeepAlive int // Seconds Retained bool AutoReconnect bool ConnectTimeout int // Seconds pkg.TlsConfigurationOptions }
MQTTClientOptions contains the client options which are loaded via reflection
func CreateMQTTClientOptionsWithDefaults ¶
func CreateMQTTClientOptionsWithDefaults() MQTTClientOptions
CreateMQTTClientOptionsWithDefaults constructs MQTTClientOptions instance with defaults.
type MessageMarshaller ¶
MessageMarshaller defines the function signature for marshaling structs into []byte.
type MessageUnmarshaller ¶
MessageUnmarshaller 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