Documentation ¶
Index ¶
- Constants
- type Client
- func (mc *Client) Connect() error
- func (mc *Client) Disconnect() error
- func (mc *Client) Publish(message types.MessageEnvelope, topic string) error
- func (mc *Client) Request(message types.MessageEnvelope, requestTopic string, responseTopicPrefix string, ...) (*types.MessageEnvelope, error)
- func (mc *Client) Subscribe(topics []types.TopicChannel, messageErrors chan error) error
- func (mc *Client) Unsubscribe(topics ...string) error
- type ClientCreator
- type ConnectionOptions
- type MQTTClientConfig
- type MQTTClientOptions
- type MessageMarshaller
- type MessageUnmarshaller
- type OperationErr
- type TimeoutErr
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.
func (*Client) Publish ¶
func (mc *Client) Publish(message types.MessageEnvelope, topic string) error
Publish sends a message to the connected MQTT server.
func (*Client) Request ¶
func (mc *Client) Request(message types.MessageEnvelope, requestTopic string, responseTopicPrefix string, timeout time.Duration) (*types.MessageEnvelope, error)
Request publishes a request and waits for a response
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, caCertCreator pkg.X509CaCertCreator, caCertLoader pkg.X509CaCertLoader, pemDecoder pkg.PEMDecoder) 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 CleanSession bool // MQTT Default is true if never set 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