pkg

package
v0.0.0-...-3b4a62d Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRequireHost                 = fmt.Errorf("broker require host")
	ErrInvalidPort                 = fmt.Errorf("borker invalid port")
	ErrRequireClientId             = fmt.Errorf("broker require client id")
	ErrRequireUsername             = fmt.Errorf("broker require username")
	ErrRequirePassword             = fmt.Errorf("broker require password")
	ErrInvalidReconnectInterval    = fmt.Errorf("broker reconnect must be at least 5 second")
	ErrInvalidMaxReconnectInterval = fmt.Errorf("broker reconnect must be at least 1 hour")
)

Functions

func NewClient

func NewClient(cfg *Config) mqtt.Client

Types

type Config

type Config struct {
	Host                 string
	Port                 uint
	ClientId             string
	Username             string
	Password             string
	PingTimeout          uint
	KeepAlive            uint
	ReconnectInterval    uint
	MaxReconnectInterval uint
}

func (*Config) Get

func (c *Config) Get() *mqtt.ClientOptions

func (*Config) Validate

func (c *Config) Validate() error

type Publisher

type Publisher struct {
	Topic    string
	QoS      byte
	Retained bool
	Client   mqtt.Client
}

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, msg any) error

type Subscriber

type Subscriber struct {
	Topic   string
	QoS     byte
	Handler mqtt.MessageHandler
	Config  *Config
	// contains filtered or unexported fields
}

func (*Subscriber) Close

func (s *Subscriber) Close(quiesce uint)

func (*Subscriber) Listen

func (s *Subscriber) Listen(ctx context.Context)

Jump to

Keyboard shortcuts

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