framework: github.com/openchirp/framework/pubsub Index | Files

package pubsub

import "github.com/openchirp/framework/pubsub"

Package pubsub hold the interfaces and utilities to work with the PubSub side of the OpenChirp framework

Index

Package Files

bridge.go importpath.go mqttclient.go pubsub.go

Constants

const (
    QoSAtMostOnce  = MQTTQoS(0)
    QoSAtLeastOnce = MQTTQoS(1)
    QoSExactlyOnce = MQTTQoS(2)
    QoSUnknown     = MQTTQoS(0xFF)
)

Variables

var (
    // Sets whether AutoReconnect will be set
    AutoReconnect bool = true
)

func GenMQTTClientID Uses

func GenMQTTClientID(prefix string) (string, error)

GenMQTTClientID generates a random client id for mqtt

type Bridge Uses

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

Bridge holds configuration for a PubSub bridge

func NewBridge Uses

func NewBridge(pubsuba, pubsubb PubSub, log *logrus.Logger) *Bridge

NewBridge instantiates a PubSub bridge that allows you to map topics from one pubsub interface to another and the reverse. The log is used to declare errors when publishing asynchronously.

func (*Bridge) AddFwd Uses

func (b *Bridge) AddFwd(deviceid, topica string, callback func(pubsubb PubSub, topica string, payload []byte) error) error

func (*Bridge) AddLinkFwd Uses

func (b *Bridge) AddLinkFwd(deviceid, topica string, topicb ...string) error

func (*Bridge) AddLinkRev Uses

func (b *Bridge) AddLinkRev(deviceid, topicb string, topica ...string) error

func (*Bridge) AddRev Uses

func (b *Bridge) AddRev(deviceid, topicb string, callback func(pubsuba PubSub, topicb string, payload []byte) error) error

func (*Bridge) IsDeviceLinked Uses

func (b *Bridge) IsDeviceLinked(deviceid string) bool

func (*Bridge) IsLinkFwd Uses

func (b *Bridge) IsLinkFwd(deviceid, topica string) bool

func (*Bridge) IsLinkRev Uses

func (b *Bridge) IsLinkRev(deviceid, topicb string) bool

func (*Bridge) RemoveLinksAll Uses

func (b *Bridge) RemoveLinksAll(deviceid string) error

type MQTTClient Uses

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

func NewMQTTBridgeClient Uses

func NewMQTTBridgeClient(
    brokerURI, user, pass string,
    defaultQoS MQTTQoS,
    defaultPersistence bool) (*MQTTClient, error)

NewMQTTBridgeClient creates and connects an MQTT client that implements the PubSub interface. This special variant will indicate to the broker that you are operating as a MQTT bridge. In this case, you will not receive an echo of messages you publish to a topic you have subscribed to. Note, this is not an official MQTT feature and is only supported by a few brokers. Checkout https://github.com/mqtt/mqtt.github.io/wiki/bridge_protocol for more info.

func NewMQTTClient Uses

func NewMQTTClient(
    brokerURI, user, pass string,
    defaultQoS MQTTQoS,
    defaultPersistence bool) (*MQTTClient, error)

NewMQTTClient creates and connects an MQTT client that implements the PubSub interface

func NewMQTTWillBridgeClient Uses

func NewMQTTWillBridgeClient(
    brokerURI, user, pass string,
    defaultQoS MQTTQoS,
    defaultPersistence bool,
    willTopic string,
    willPayload []byte) (*MQTTClient, error)

NewMQTTWillBridgeClient creates and connects an MQTT client that implements the PubSub interface and sets a will message. This special variant will indicate to the broker that you are operating as a MQTT bridge. In this case, you will not receive an echo of messages you publish to a topic you have subscribed to. Note, this is not an official MQTT feature and is only supported by a few brokers. Checkout https://github.com/mqtt/mqtt.github.io/wiki/bridge_protocol for more info.

func NewMQTTWillClient Uses

func NewMQTTWillClient(
    brokerURI, user, pass string,
    defaultQoS MQTTQoS,
    defaultPersistence bool,
    willTopic string,
    willPayload []byte) (*MQTTClient, error)

NewMQTTWillClient creates and connects an MQTT client that implements the PubSub interface and sets a will message.

func (*MQTTClient) Disconnect Uses

func (c *MQTTClient) Disconnect()

func (*MQTTClient) Publish Uses

func (c *MQTTClient) Publish(topic string, payload interface{}) error

func (*MQTTClient) Subscribe Uses

func (c *MQTTClient) Subscribe(topic string, callback func(topic string, payload []byte)) error

func (*MQTTClient) Unsubscribe Uses

func (c *MQTTClient) Unsubscribe(topics ...string) error

type MQTTQoS Uses

type MQTTQoS byte

func ParseMQTTQoS Uses

func ParseMQTTQoS(QoS string) MQTTQoS

type PubSub Uses

type PubSub interface {
    Subscribe(topic string, callback func(topic string, payload []byte)) error
    Unsubscribe(topics ...string) error
    Publish(topic string, payload interface{}) error
}

PubSub is the most basic PubSub interface

Package pubsub imports 6 packages (graph) and is imported by 4 packages. Updated 2019-01-07. Refresh now. Tools for package owners.