mosquitto

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2021 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, host string, callback EventFunc) (*Client, error)

New client connection to a broker, which will callback on events

func NewWithConfig

func NewWithConfig(ctx context.Context, cfg Config) (*Client, error)

New client connection with additional configuration

func (*Client) Close

func (c *Client) Close() error

func (*Client) Publish

func (c *Client) Publish(topic string, data []byte, opts ...ClientOpt) (int, error)

func (*Client) PublishJSON

func (c *Client) PublishJSON(topic string, data interface{}, opts ...ClientOpt) (int, error)

func (*Client) String

func (c *Client) String() string

func (*Client) Subscribe

func (c *Client) Subscribe(topics string, opts ...ClientOpt) (int, error)

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(topics string) (int, error)

func (*Client) Version

func (c *Client) Version() string

type ClientOpt

type ClientOpt func(opts *opts)

func OptAtLeastOnce

func OptAtLeastOnce() ClientOpt

Standard delivery

func OptAtMostOnce

func OptAtMostOnce() ClientOpt

Best efforts delivery

func OptExactlyOnce

func OptExactlyOnce() ClientOpt

Guaranteed (?) delivery

func OptQoS

func OptQoS(qos int) ClientOpt

Custom QoS

func OptRetain

func OptRetain() ClientOpt

Make the message retained

type Config

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

func NewConfigWithBroker

func NewConfigWithBroker(host string) Config

Create a new empty configuration

func (Config) WithCallback

func (c Config) WithCallback(fn EventFunc) Config

func (Config) WithClientId

func (c Config) WithClientId(v string) Config

func (Config) WithCredentials

func (c Config) WithCredentials(user, password string) Config

func (Config) WithHost

func (c Config) WithHost(v string) Config

func (Config) WithKeepalive

func (c Config) WithKeepalive(d time.Duration) Config

func (Config) WithTLS

func (c Config) WithTLS(capath, certpath, keypath string, verify bool) Config

func (Config) WithTrace

func (c Config) WithTrace(fn TraceFunc) Config

type Event

type Event struct {
	Type  Flags
	Err   error
	Id    int
	Topic string
	Data  []byte
}

func NewConnect

func NewConnect(err error) *Event

func NewDisconnect

func NewDisconnect(err error) *Event

func NewMessage

func NewMessage(id int, topic string, data []byte) *Event

func NewPublish

func NewPublish(id int) *Event

func NewSubscribe

func NewSubscribe(id int) *Event

func NewUnsubscribe

func NewUnsubscribe(id int) *Event

func (*Event) String

func (e *Event) String() string

type EventFunc

type EventFunc func(*Event)

type TraceFunc

type TraceFunc func(string)

Jump to

Keyboard shortcuts

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