mqttClient

package
v3.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Name() string
	GetCtx() context.Context
	Run()
	Shutdown()
	Publish(topic string, payload []byte, qos byte, retain bool)
	AddRoute(subscribeTopic string, messageHandler MessageHandler)
}

type ClientStruct

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

func NewV5

func NewV5(
	cfg Config,
) (client *ClientStruct)

func (*ClientStruct) AddRoute

func (c *ClientStruct) AddRoute(subscribeTopic string, messageHandler MessageHandler)

func (*ClientStruct) GetCtx

func (c *ClientStruct) GetCtx() context.Context

func (*ClientStruct) Name

func (c *ClientStruct) Name() string

func (*ClientStruct) Publish

func (c *ClientStruct) Publish(topic string, payload []byte, qos byte, retain bool)

func (*ClientStruct) Run

func (c *ClientStruct) Run()

func (*ClientStruct) Shutdown

func (c *ClientStruct) Shutdown()

type Config

type Config interface {
	Name() string
	Broker() *url.URL

	User() string
	Password() string
	ClientId() string

	KeepAlive() time.Duration
	ConnectRetryDelay() time.Duration
	ConnectTimeout() time.Duration
	TopicPrefix() string
	ReadOnly() bool
	MaxBacklogSize() int

	AvailabilityClient() MqttSectionConfig
	AvailabilityClientTopic() string

	LogDebug() bool
	LogMessages() bool
}

type Message

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

func (Message) Payload

func (m Message) Payload() []byte

func (Message) Topic

func (m Message) Topic() string

type MessageHandler

type MessageHandler func(Message)

type MqttSectionConfig

type MqttSectionConfig interface {
	Enabled() bool
	Interval() time.Duration
	Retain() bool
	Qos() byte
}

Jump to

Keyboard shortcuts

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