mqttclient

package
v0.0.0-...-4e1b064 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMessageChannel

func GetMessageChannel() chan mqtt.Message

Types

type MQTTClient

type MQTTClient struct {
	Client mqtt.Client
	Config MQTTConfig
	// contains filtered or unexported fields
}

MQTTClient is the interface for the MQTT client

func NewMQTTClient

func NewMQTTClient(config MQTTConfig) *MQTTClient

func (*MQTTClient) Connect

func (m *MQTTClient) Connect() error

func (*MQTTClient) Disconnect

func (m *MQTTClient) Disconnect()

func (*MQTTClient) Subscribe

func (m *MQTTClient) Subscribe() error

type MQTTConfig

type MQTTConfig struct {
	Broker                string
	Port                  int
	ClientID              string
	Topic                 string
	Qos                   byte
	CleanSession          bool
	KeepAlive             int
	ReconnectOnDisconnect bool
	Username              string
	Password              string
}

MQTTConfig is the configuration for the MQTT client

type MessageQueue

type MessageQueue struct {
	// contains filtered or unexported fields
}

MessageQueue handles queuing and processing messages

func NewMessageQueue

func NewMessageQueue(bufferSize int, workers int) *MessageQueue

NewMessageQueue creates a new message queue with a specified buffer size

func (*MessageQueue) Enqueue

func (mq *MessageQueue) Enqueue(msg mqtt.Message)

Enqueue adds a message to the queue

func (*MessageQueue) StartProcessing

func (mq *MessageQueue) StartProcessing(handler func(mqtt.Message))

StartProcessing starts worker goroutines to process messages from the queue

func (*MessageQueue) StopProcessing

func (mq *MessageQueue) StopProcessing()

StopProcessing signals workers to stop and waits for them to finish

Jump to

Keyboard shortcuts

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