bus

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff added in v0.7.0

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

Backoff implements a basic increasing backoff strategy with a small amount of random jitter

func NewBackoff added in v0.7.0

func NewBackoff() *Backoff

NewBackoff returns a freshly initialized Backoff

func (*Backoff) Reset added in v0.7.0

func (b *Backoff) Reset()

Reset restarts wait interval escalation

func (*Backoff) Wait added in v0.7.0

func (b *Backoff) Wait()

Wait calculates the next backoff interval, sleeps for that amount and returns.

type Connection added in v0.7.0

type Connection interface {
	Connect(options ConnectionOptions) error
	Disconnect() error
	Publish(topic string, payload []byte) error
	Subscribe(topic string, handler SubscriptionHandler) error
}

Connection is the high-level message bus interface

type ConnectionOptions added in v0.7.0

type ConnectionOptions struct {
	Userid        string
	Password      string
	Host          string
	Port          int
	SSLEnabled    bool
	SSLCertPath   string
	EventsHandler EventHandler
	AutoReconnect bool
	OnDisconnect  *DisconnectMessage
}

ConnectionOptions describe how to configure a bus.Connection

type DisconnectMessage added in v0.7.0

type DisconnectMessage struct {
	Topic string
	Body  string
}

DisconnectMessage is sent when the connection is broken

type Event added in v0.7.0

type Event int

Event describes different events which can happen over the life of a connection. Currently only BusConnection is supported.

const (
	// ConnectedEvent indicates a working bus connection has been
	// established
	ConnectedEvent Event = iota
)

type EventHandler added in v0.7.0

type EventHandler func(conn Connection, event Event)

EventHandler is called when a bus event occurs.

type MQTTConnection added in v0.7.0

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

MQTTConnection is a MQTT-specific implementation of bus.Connection

func (*MQTTConnection) Connect added in v0.7.0

func (mqc *MQTTConnection) Connect(options ConnectionOptions) error

Connect is required by the bus.Connection interface

func (*MQTTConnection) Disconnect added in v0.9.0

func (mqc *MQTTConnection) Disconnect() error

Disconnect is required by the bus.Connection interface

func (*MQTTConnection) Publish added in v0.7.0

func (mqc *MQTTConnection) Publish(topic string, payload []byte) error

Publish is required by the bus.Connection interface

func (*MQTTConnection) Subscribe added in v0.7.0

func (mqc *MQTTConnection) Subscribe(topic string, handler SubscriptionHandler) error

Subscribe is required by the bus.Connection interface

type MessagePublisher added in v0.7.0

type MessagePublisher interface {
	Publish(topic string, message []byte) error
}

MessagePublisher sends messages on the message bus

type SubscriptionHandler added in v0.7.0

type SubscriptionHandler func(conn Connection, topic string, message []byte)

SubscriptionHandler is called when a message is received on its corresponding topic subscription

Jump to

Keyboard shortcuts

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