Documentation
¶
Index ¶
Constants ¶
const ( // Different Client operations. PublishOperation = "Publish" SubscribeOperation = "Subscribe" ConnectOperation = "Connect" )
Variables ¶
var TlsSchemes = []string{"tcps", "ssl", "tls"}
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 ClientCreatorWithCertLoader ¶ added in v0.1.16
func ClientCreatorWithCertLoader(certCreator X509KeyPairCreator, certLoader 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 // TLS configuration SkipCertVerify bool CertFile string KeyFile string KeyPEMBlock string CertPEMBlock string }
MQTTClientOptions contains the client options which are loaded via reflection
func CreateMQTTClientOptionsWithDefaults ¶
func CreateMQTTClientOptionsWithDefaults() MQTTClientOptions
CreateMQTTClientOptionsWithDefaults constructs MQTTClientOptions instance with defaults.
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
type X509KeyLoader ¶ added in v0.1.16
type X509KeyLoader func(certFile string, keyFile string) (tls.Certificate, error)
X509KeyLoader defines a function signature for loading a tls.Certificate from cert and key files.
type X509KeyPairCreator ¶ added in v0.1.16
type X509KeyPairCreator func(certPEMBlock []byte, keyPEMBlock []byte) (tls.Certificate, error)
X509KeyPairCreator defines the function signature for creating a tls.Certificate based on PEM encoding.