mqtt

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package mqtt provides a real-time MQTT-based interface for PostgreSQL, similar to how PostgREST exposes PostgreSQL over HTTP.

Index

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) Connect

func (c *Client) Connect() error

Connect establishes a connection to the MQTT broker.

func (*Client) Disconnect

func (c *Client) Disconnect()

Disconnect closes the connection to the MQTT broker.

func (*Client) Publish

func (c *Client) Publish(topic string, qos byte, retained bool, payload interface{}) error

Publish sends a message to the specified MQTT topic.

func (*Client) Subscribe

func (c *Client) Subscribe(topic string, qos byte, callback mqtt.MessageHandler) error

Subscribe registers a callback for messages on the specified MQTT topic.

type ClientOptions

type ClientOptions struct {
	Store                  mqtt.Store
	OnConnectAttempt       mqtt.ConnectionAttemptHandler
	CustomOpenConnectionFn mqtt.OpenConnectionFunc
	DefaultPublishHandler  mqtt.MessageHandler
	CredentialsProvider    mqtt.CredentialsProvider
	HTTPHeaders            http.Header
	Dialer                 *net.Dialer
	WebsocketOptions       *mqtt.WebsocketOptions
	OnConnect              mqtt.OnConnectHandler
	OnConnectionLost       mqtt.ConnectionLostHandler
	OnReconnecting         mqtt.ReconnectHandler
	TLSConfig              *tls.Config
	ClientID               string `json:"clientID"`
	WillTopic              string
	Username               string     `json:"username"`
	Password               string     `json:"password"`
	Servers                []*url.URL `json:"servers"`
	WillPayload            []byte
	WriteTimeout           time.Duration
	ConnectRetryInterval   time.Duration
	MaxResumePubInFlight   int
	MessageChannelDepth    uint
	MaxReconnectInterval   time.Duration
	ConnectTimeout         time.Duration
	PingTimeout            time.Duration
	KeepAlive              int64
	ProtocolVersion        uint
	WillRetained           bool
	AutoReconnect          bool
	ResumeSubs             bool
	WillQos                byte
	WillEnabled            bool
	ConnectRetry           bool
	Order                  bool
	CleanSession           bool
	AutoAckDisabled        bool
}

type Config

type Config struct {
	Servers       []string `json:"servers"`
	TopicPrefix   string   `json:"topicPrefix"`
	ClientOptions `json:"clientOptions"`
}

type PeerMQTT

type PeerMQTT struct {
	*Client
	Config Config
}

PeerMQTT implements the source and sink functionality for MQTT

func (*PeerMQTT) Connect

func (p *PeerMQTT) Connect(config json.RawMessage, args ...any) error

func (*PeerMQTT) Disconnect

func (p *PeerMQTT) Disconnect() error

func (*PeerMQTT) Pub

func (p *PeerMQTT) Pub(event cdc.Event, args ...any) error

func (*PeerMQTT) Sub

func (p *PeerMQTT) Sub(args ...any) (<-chan cdc.Event, error)

func (*PeerMQTT) Type

func (p *PeerMQTT) Type() pipeline.ConnectorType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL