mqtt

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoConnection = errors.New("no connection to broker server")

Functions

This section is empty.

Types

type MQTTBroker

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

MQTTBroker implements broker.Broker interface.

func NewBroker

func NewBroker(opts ...Option) (*MQTTBroker, error)

NewBroker creates new mqtt broker.

func (*MQTTBroker) Connect

func (m *MQTTBroker) Connect() error

func (*MQTTBroker) ConnectAndSubscribe added in v1.0.16

func (m *MQTTBroker) ConnectAndSubscribe(subHandler broker.Handler, subTopics []string) error

connect and update option to auto resubscribe with option OnConnect

func (*MQTTBroker) Disconnect

func (m *MQTTBroker) Disconnect() error

func (*MQTTBroker) Publish

func (m *MQTTBroker) Publish(topic string, payload interface{}) error

func (*MQTTBroker) String

func (m *MQTTBroker) String() string

func (*MQTTBroker) Subscribe

func (m *MQTTBroker) Subscribe(topics []string, h broker.Handler) error

type Option

type Option func(m *MQTTBroker) error

func WithClientID

func WithClientID(id string) Option

WithClientID returns an Option which set the broker client id.

func WithLogger added in v1.0.16

func WithLogger(logger *zap.Logger) Option

WithLogger returns an Option which set the logger to use when connect to server.

func WithPassword

func WithPassword(password string) Option

WithPassword returns an Option which set the password use to connect to server.

func WithURL

func WithURL(u string) Option

WithURL returns an Option which set the broker url.

func WithUsername

func WithUsername(username string) Option

WithUsername returns an Option which set the username use to connect to server.

Jump to

Keyboard shortcuts

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