mqtt

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

README

MQTT Broker

The MQTT broker is useful for IoT based applications

Usage

Drop in import

import _ "github.com/micro/go-plugins/broker/mqtt"

Flag on command line

go run main.go --broker=mqtt

Alternatively use directly

import (
	"github.com/micro/go-micro"
	"github.com/micro/go-plugins/broker/mqtt"
)


func main() {
	service := micro.NewService(
		micro.Name("my.service"),
		micro.Broker(mqtt.NewBroker()),
	)
}

Encoding

Because MQTT does not support message headers the plugin encodes messages using JSON. If you prefer to send and receive the mqtt payload uninterpreted use the noop codec.

Example

import (
    "github.com/micro/broker"
    "github.com/micro/broker/codec/noop"
    "github.com/micro/go-plugins/broker/mqtt"
)

b := mqtt.NewBroker(
    broker.Codec(noop.NewCodec()),
)

Documentation

Overview

Package mqtt provides an mqtt broker

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBroker

func NewBroker(opts ...broker.Option) broker.Broker

func Password added in v1.5.4

func Password(value string) broker.Option

func Username added in v1.5.4

func Username(value string) broker.Option

Types

This section is empty.

Jump to

Keyboard shortcuts

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