mqtt

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPublishOption = PublishOption{
	QoS:     0,
	Retain:  false,
	Timeout: 5 * time.Second,
}
View Source
var DefaultSubscribeOption = SubscribeOption{
	QoS:     0,
	Timeout: 5 * time.Second,
}

Functions

func Client

func Client() (mqtt.Client, error)

Client returns the MQTT client instance

func Close

func Close() error

Close closes the MQTT client connection

func Health

func Health() error

Health checks if the MQTT client is connected

func Init

func Init() (err error)

func New

func New(cfg config.Mqtt) (mqtt.Client, error)

func Publish

func Publish(topic string, payload any, opts ...PublishOption) error

func Subscribe

func Subscribe(topic string, handler MessageHandler, opts ...SubscribeOption) error

func Unsubscribe

func Unsubscribe(topics ...string) error

Types

type MessageHandler

type MessageHandler func(topic string, payload []byte) error

type PublishOption

type PublishOption struct {
	QoS     byte
	Retain  bool
	Timeout time.Duration
}

type SubscribeOption

type SubscribeOption struct {
	QoS     byte
	Timeout time.Duration
}

Jump to

Keyboard shortcuts

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