mqtt5

package
v1.0.23 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDialTimeOut = 30
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageClient added in v1.0.3

type MessageClient interface {
	// SetAuthData sets up message bus auth data
	SetAuthData(secretProvider interfaces.SecretProvider) errors.Error

	// Connect to messaging host specified in Mqtt5Config config
	// returns error if not able to connect
	Connect() errors.Error

	// Disconnect is to close all connections on the message bus
	Disconnect() errors.Error

	// Subscribe is to receive messages from topics
	// the function returns error for any subscribe error
	Subscribe(topics []string, handlerType any) errors.Error

	// Unsubscribe to unsubscribe from the specified topics.
	Unsubscribe(topics []string) errors.Error

	// Publish is to send message to the message bus
	// the message contains data payload to send to the message queue
	Publish(topic string, message models.MessageEnvelope) errors.Error
}

MessageClient is the messaging interface for publisher-subscriber pattern

type Mqtt5Client

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

func NewMqtt5Client

func NewMqtt5Client(logger log.Logger, ctx context.Context, config models.Mqtt5Config) Mqtt5Client

NewMqtt5Client create, initializes and returns new instance of Mqtt5Client

func (*Mqtt5Client) Connect

func (c *Mqtt5Client) Connect() errors.Error

Connect establishes a connection to a MQTT server.

func (*Mqtt5Client) Disconnect

func (c *Mqtt5Client) Disconnect() errors.Error

Disconnect closes the connection to the connected MQTT server.

func (*Mqtt5Client) Publish added in v1.0.5

func (c *Mqtt5Client) Publish(topic string, message models.MessageEnvelope) errors.Error

Publish sends a message to the connected MQTT server.

func (*Mqtt5Client) SetAuthData

func (c *Mqtt5Client) SetAuthData(secretProvider interfaces.SecretProvider) errors.Error

SetAuthData retrieves and sets up auth data from secret provider according to AuthMode and SecretName

func (*Mqtt5Client) Subscribe added in v1.0.3

func (c *Mqtt5Client) Subscribe(topics []string, handlerType any) errors.Error

Subscribe creates subscriptions for the specified topics and the message handler. Only support two handleType: paho.MessageHandler and chan models.MessageEnvelope There is a known issue when using wildcard to subscribe the duplicated messages: https://github.com/eclipse/paho.golang/issues/204 https://github.com/eclipse/mosquitto/issues/2555

func (*Mqtt5Client) Unsubscribe added in v1.0.3

func (c *Mqtt5Client) Unsubscribe(topics []string) errors.Error

Unsubscribe to unsubscribe from the specified topics.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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