Documentation ¶
Index ¶
- func ClientID() string
- type Client
- func (m *Client) Cleanup(topic string, retained bool) error
- func (m *Client) ConnectionHandler(client paho.Client)
- func (m *Client) ConnectionLostHandler(client paho.Client, reason error)
- func (m *Client) Listen(topic string, callback func(string)) error
- func (m *Client) ListenSetter(topic string, callback func(string) error) error
- func (m *Client) Publish(topic string, retained bool, payload interface{}) error
- func (m *Client) WaitForToken(action, topic string, token paho.Token)
- type Config
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
Client encapsulates mqtt publish/subscribe functions
var Instance *Client
Instance is the paho Mqtt client singleton
func NewClient ¶
func NewClient(log *util.Logger, broker, user, password, clientID string, qos byte, insecure bool, caCert, clientCert, clientKey string, opts ...Option) (*Client, error)
NewClient creates new Mqtt publisher
func RegisteredClient ¶
func RegisteredClient(log *util.Logger, broker, user, password, clientID string, qos byte, insecure bool, caCert, clientCert, clientKey string, opts ...Option) (*Client, error)
RegisteredClient reuses an registered Mqtt publisher or creates a new one
func RegisteredClientOrDefault ¶
RegisteredClientOrDefault reuses an registered Mqtt publisher or creates a new one. If no publisher is configured, it uses the default instance.
func (*Client) ConnectionHandler ¶
ConnectionHandler restores listeners
func (*Client) ConnectionLostHandler ¶
ConnectionLostHandler logs cause of connection loss as warning
func (*Client) ListenSetter ¶
ListenSetter creates a /set listener that resets the payload after handling
type Config ¶
type Config struct { Broker string `json:"broker"` User string `json:"user"` Password string `json:"password"` ClientID string `json:"clientID"` Insecure bool `json:"insecure"` CaCert string `json:"caCert"` ClientCert string `json:"clientCert"` ClientKey string `json:"clientKey"` }
Config is the public configuration
type Option ¶
type Option func(*paho.ClientOptions)
Click to show internal directories.
Click to hide internal directories.