mqtt

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrParsingTopicName is error emit when parsing of topic failed
	ErrParsingTopicName = errors.New("failure on parsing topic name to extract meta data")
)

Functions

This section is empty.

Types

type MQTT

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

MQTT is a concrete implementation of Subscriber that using underlying MQTT protocol

func NewMQTT

func NewMQTT(opts ...OptionFunc) *MQTT

NewMQTT returns a new instance of MQTT Subscriber

func (*MQTT) Connect

func (m *MQTT) Connect() (mqtt.Client, error)

Connect try to establish a connection with the MQTT Broker

func (*MQTT) Logger

func (m *MQTT) Logger() logr.Logger

Logger returns the underlying logger

func (*MQTT) SetCollector

func (m *MQTT) SetCollector(c collector.Collector)

SetCollector inject a collector inside the subscriber

func (*MQTT) SetLogger

func (m *MQTT) SetLogger(log logr.Logger)

SetLogger set the logger

func (*MQTT) Subscribe

func (m *MQTT) Subscribe() error

Subscribe open a connection with the MQTT Broker and subscriber to each declare topics

type OptionFunc

type OptionFunc func(m *MQTT)

OptionFunc defines option functions for MQTT instances

func OptionWithAddress

func OptionWithAddress(a string) OptionFunc

OptionWithAddress set MQTT endpoint

func OptionWithCollector

func OptionWithCollector(c collector.Collector) OptionFunc

OptionWithCollector inject a collector

func OptionWithLogger

func OptionWithLogger(log logr.Logger) OptionFunc

OptionWithLogger to set logger

func OptionWithTopics

func OptionWithTopics(topics ...string) OptionFunc

OptionWithTopics appends topics to existing topics

Jump to

Keyboard shortcuts

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