publisher

package
v0.0.0-...-31e8ef2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MQTTQOSOne is a constant representing QOS level 1 when publishing.
	MQTTQOSOne = byte(1)
)

Variables

View Source
var (
	// ErrPublishTimeout should only happen if the broker is unresponsive.
	ErrPublishTimeout = errors.New("mqtt publish timed out")
)

Functions

This section is empty.

Types

type MQTTOptions

type MQTTOptions struct {
	Topic       string
	Telemetry   string
	Broker      string
	ClientID    string
	TLSKeyFile  string
	TLSCertFile string
}

MQTTOptions controls how the internal mqtt client is created.

type MQTTPublisher

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

MQTTPublisher knows how to Publish a collect.Msg to a given topic on its connected broker.

func NewMQTT

func NewMQTT(o MQTTOptions) *MQTTPublisher

NewMQTT creates an MQTTPublisher from the given options.

func (*MQTTPublisher) Close

func (m *MQTTPublisher) Close()

Close disconnects from the broker.

func (*MQTTPublisher) Connect

func (m *MQTTPublisher) Connect(ctx context.Context) error

Connect initiates a client MQTT connection to the configured broker.

func (*MQTTPublisher) Publish

func (m *MQTTPublisher) Publish(ctx context.Context, msg *collect.Msg) error

Publish encodes a collect.Msg into json and sends it to the broker with QoS level 1.

Jump to

Keyboard shortcuts

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