mqtt

package module
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ConnectionFailureError = NewMQTTError("connection failure")
	EmptyTopicError        = NewMQTTError("subscribe top cannot be empty string")
	NillHandlerError       = NewMQTTError("subscribe handler cannot be nil")
	NillPayloadError       = NewMQTTError("publish payload cannot be nil")
	InvalidQoSError        = NewMQTTError("qos must be one of: byte(0), byte(1) or byte(2)")
)

Functions

func LogMessage

func LogMessage(msg ...string) string

func NewMQTTError

func NewMQTTError(msg string) error

func ValidateQoS

func ValidateQoS(qos QoS) bool

Types

type Handler

type Handler = func(topic string, qos QoS, payload []byte) error

type MQTTClient added in v1.17.0

type MQTTClient interface {
	Connect() error
	Client() myQTT.Client
}

func NewMQTTClient

func NewMQTTClient(cfgs *configs.Configs, logger logging.Logger) MQTTClient

type MQTTDispatcher

type MQTTDispatcher interface {
	Register(topic string, qos QoS, handler Handler) error
	ConsumeBlocking(ch chan os.Signal)
}

func NewMQTTDispatcher added in v1.17.0

func NewMQTTDispatcher(logger logging.Logger, client myQTT.Client) MQTTDispatcher

type MQTTError

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

func (*MQTTError) Error

func (e *MQTTError) Error() string

type MQTTPublisher

type MQTTPublisher interface {
	Pub(topic string, qos QoS, payload any) error
	PubRetained(topic string, qos QoS, payload any) error
}

func NewMQTTPublisher

func NewMQTTPublisher(logger logging.Logger, client myQTT.Client) MQTTPublisher

type QoS

type QoS byte
var (
	AtMostOnce  QoS = 0
	AtLeastOnce QoS = 1
	ExactlyOnce QoS = 2
)

func QoSFromBytes

func QoSFromBytes(qos byte) QoS

Jump to

Keyboard shortcuts

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