mqtt

package
v0.0.0-...-99d84d4 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeliveryKey = "mqtt.Message"
)

Variables

This section is empty.

Functions

func Delivery

func Delivery(ctx context.Context) mqtt.Message

Delivery returns the mqtt.Message message from a context when used by a worker task

func Message

func Message(ctx context.Context) []byte

Message returns the message content from a context when used by a worker task

Types

type MQ

type MQ struct {
	// Url to connect to
	Url      string `yaml:"url"`
	ClientID string `yaml:"clientID"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Debug    bool   `yaml:"debug"`
	// contains filtered or unexported fields
}

func (*MQ) Log

func (s *MQ) Log(f string, a ...interface{})

func (*MQ) Subscribe

func (s *MQ) Subscribe(topic string, h MessageHandler) error

type MessageHandler

type MessageHandler func(mqtt.Message)

func ContextTask

func ContextTask(f task.Task, ctx context.Context) MessageHandler

func (MessageHandler) Do

func (a MessageHandler) Do(m mqtt.Message)

func (MessageHandler) Then

type Pool

type Pool interface {
	GetMQ(string) *MQ
}

type Publisher

type Publisher struct {
	Topic    string `yaml:"topic"`              // Topic to publish to
	Retained bool   `yaml:"retained,omitempty"` // true if message to be retained
	// contains filtered or unexported fields
}

func (*Publisher) Bind

func (p *Publisher) Bind(broker *MQ) error

func (*Publisher) Publish

func (p *Publisher) Publish(message []byte) error

type Queue

type Queue struct {
	Broker string `yaml:"broker"`
	Topic  string `yaml:"topic"`
	// contains filtered or unexported fields
}

func (*Queue) AddHandler

func (q *Queue) AddHandler(h MessageHandler)

func (*Queue) Bind

func (q *Queue) Bind(broker *MQ) error

Jump to

Keyboard shortcuts

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