mqttwatermill

package
v0.0.0-...-db5373c Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetadataTopic     = "mqtt_topic"
	MetadataQoS       = "mqtt_qos"
	MetadataRetained  = "mqtt_retained"
	MetadataMessageID = "mqtt_message_id"
	MetadataDuplicate = "mqtt_duplicate"
)

Variables

This section is empty.

Functions

func NewPublisher

func NewPublisher(client *mqttlib.Client, logger *slog.Logger) (message.Publisher, error)

NewPublisher creates a new MQTT Publisher

func NewSubscriber

func NewSubscriber(client *mqttlib.Client, logger *slog.Logger) (message.Subscriber, error)

NewSubscriber creates a new MQTT Subscriber

Types

type PubSubRouter

type PubSubRouter struct {
	Logger *slog.Logger

	// Subscriber is the Watermill Subscriber to receive messages from MQTT
	Subscriber message.Subscriber

	// Publisher is the Watermill Publisher to send messages to
	Publisher message.Publisher

	Router *message.Router
	// contains filtered or unexported fields
}

PubSubRouter is a Watermill Router implementation that routes messages to GCP Pub/Sub

func NewPubSubRouter

func NewPubSubRouter(cfg PubSubRouterConfig, logger *slog.Logger) (*PubSubRouter, error)

NewPubSubRouter creates a new PubSubRouter

func (*PubSubRouter) Close

func (r *PubSubRouter) Close() error

func (*PubSubRouter) Start

func (r *PubSubRouter) Start(ctx context.Context) error

type PubSubRouterConfig

type PubSubRouterConfig struct {
	ProjectID       string
	SubscriberTopic string
	PublisherTopic  string
	MqttClient      *mqttlib.Client
	HandlerName     string
}

type Publisher

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

Publisher is a Watermill Publisher implementation for MQTT

func (*Publisher) Close

func (p *Publisher) Close() error

Close closes the publisher

func (*Publisher) Publish

func (p *Publisher) Publish(topic string, messages ...*message.Message) error

Publish publishes messages to MQTT

type Subscriber

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

Subscriber is a Watermill Subscriber implementation for MQTT

func (*Subscriber) Close

func (s *Subscriber) Close() error

Close closes the subscriber

func (*Subscriber) Subscribe

func (s *Subscriber) Subscribe(ctx context.Context, topic string) (<-chan *message.Message, error)

Subscribe subscribes to MQTT topics

Jump to

Keyboard shortcuts

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