Documentation ¶
Index ¶
- type Client
- func (c *Client) Connect() error
- func (c *Client) Disconnect()
- func (c *Client) MessageToPostgres(client mqtt.Client, msg mqtt.Message)
- func (c *Client) Publish(topic string, qos byte, retained bool, payload interface{}) error
- func (c *Client) Subscribe(topic string, qos byte, callback mqtt.MessageHandler) error
- type ClientOptions
- type PeerMQTT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents an MQTT client with PostgREST forwarding capabilities.
func NewClient ¶
func NewClient(opts *mqtt.ClientOptions, logger ...*zap.Logger) *Client
NewClient creates a new MQTT client with the given options and logger.
func (*Client) Disconnect ¶
func (c *Client) Disconnect()
Disconnect closes the connection to the MQTT broker.
func (*Client) MessageToPostgres ¶
MessageToPostgres persists an MQTT message to PostgreSQL. It expects the topic to be in the following format: topic: /pgo/TABLE_NAME/OPERATION (insert, update, delete) payload: JSON mosquitto_pub -t /pgo/users/insert -m '{"name":"some1"}'
type ClientOptions ¶
type ClientOptions struct { Servers []*url.URL `json:"servers"` ClientID string `json:"clientID"` Username string `json:"username"` Password string `json:"password"` CredentialsProvider mqtt.CredentialsProvider CleanSession bool Order bool WillEnabled bool WillTopic string WillPayload []byte WillQos byte WillRetained bool ProtocolVersion uint TLSConfig *tls.Config KeepAlive int64 // Warning: Some brokers may reject connections with Keepalive = 0. PingTimeout time.Duration ConnectTimeout time.Duration MaxReconnectInterval time.Duration AutoReconnect bool ConnectRetryInterval time.Duration ConnectRetry bool Store mqtt.Store DefaultPublishHandler mqtt.MessageHandler OnConnect mqtt.OnConnectHandler OnConnectionLost mqtt.ConnectionLostHandler OnReconnecting mqtt.ReconnectHandler OnConnectAttempt mqtt.ConnectionAttemptHandler WriteTimeout time.Duration MessageChannelDepth uint ResumeSubs bool HTTPHeaders http.Header WebsocketOptions *mqtt.WebsocketOptions MaxResumePubInFlight int // // 0 = no limit; otherwise this is the maximum simultaneous messages sent while resuming Dialer *net.Dialer CustomOpenConnectionFn mqtt.OpenConnectionFunc AutoAckDisabled bool }
Click to show internal directories.
Click to hide internal directories.