Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) AddRoute(topic string, handler paho.MessageHandler)
- func (c *Client) BufferedChannelSubscribe(topic string, qos byte, ch chan paho.Message, bufferSize int) error
- func (c *Client) ChannelSubscribe(topic string, qos byte, ch chan paho.Message) error
- func (c *Client) Close() error
- func (c *Client) Connect() (bool, error)
- func (c *Client) CustomSettings() error
- func (c *Client) Subscribe(topic string, qos byte, handler paho.MessageHandler) error
- func (c *Client) SubscribeMultiple(filters map[string]byte, handler paho.MessageHandler) error
- func (c *Client) Write(topic string, value []byte) error
- func (c *Client) WriteJson(topic string, value interface{}) error
- type Config
- type MqttHandlers
Constants ¶
View Source
const ( DefaultTimeout = 5 // seconds DefaultConnectionTimeout = 30 // seconds ErrMissingBroker = utils.Error("at least one broker must be specified") ErrInvalidProtocol = utils.Error("invalid protocol") ErrInvalidTimeout = utils.Error("invalid timeout") ErrInvalidQoSLevel = utils.Error("invalid QoS level") ErrPublishTimeout = utils.Error("timeout when publishing") ErrNilConfig = utils.Error("Config is nil") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
ClientOptions *paho.ClientOptions
Client paho.Client
QoS byte
Timeout time.Duration
Retain bool
}
func (*Client) BufferedChannelSubscribe ¶ added in v0.3.0
func (c *Client) BufferedChannelSubscribe(topic string, qos byte, ch chan paho.Message, bufferSize int) error
BufferedChannelSubscribe is an enhanced version of ChannelSubscribe with buffer size control to avoid blocking on channel sends
func (*Client) ChannelSubscribe ¶
ChannelSubscribe subscribes to a topic and sends messages to the provided channel
func (*Client) CustomSettings ¶
func (*Client) SubscribeMultiple ¶
type Config ¶
type Config struct {
Brokers []string `json:"brokers"`
Protocol string `json:"protocol"`
Username string `json:"username"`
secure.DefaultCredentialConfig // connection credential
Timeout int `json:"timeout"`
ConnectionTimeout int `json:"connectionTimeout"`
QoS int `json:"qos"`
ClientID string `json:"clientId"`
Retain bool `json:"retain"`
KeepAlive int64 `json:"keepAlive"`
AutoReconnect bool `json:"autoReconnect"`
PersistentSession bool `json:"persistentSession"`
tlsProvider.ClientConfig
MqttHandlers `json:"-"`
// contains filtered or unexported fields
}
SecureConfig struct with secure password handling
type MqttHandlers ¶
type MqttHandlers struct {
DefaultPublishHandler paho.MessageHandler
OnConnect paho.OnConnectHandler
OnConnectionLost paho.ConnectionLostHandler
OnReconnecting paho.ReconnectHandler
OnConnectAttempt paho.ConnectionAttemptHandler
CustomOpenConnectionFn paho.OpenConnectionFunc
}
Click to show internal directories.
Click to hide internal directories.