Categorygithub.com/model-collapse/paho.mqtt.golang
modulepackage
1.2.7
Repository: https://github.com/model-collapse/paho.mqtt.golang.git
Documentation: pkg.go.dev

# README

GoDoc Go Report Card

Eclipse Paho MQTT Go client

This repository contains the source code for the Eclipse Paho MQTT Go client library.

This code builds a library which enable applications to connect to an MQTT broker to publish messages, and to subscribe to topics and receive published messages.

This library supports a fully asynchronous mode of operation.

Installation and Build

This client is designed to work with the standard Go tools, so installation is as easy as:

go get github.com/eclipse/paho.mqtt.golang

The client depends on Google's proxy package and the websockets package, also easily installed with the commands:

go get github.com/gorilla/websocket
go get golang.org/x/net/proxy

Usage and API

Detailed API documentation is available by using to godoc tool, or can be browsed online using the godoc.org service.

Make use of the library by importing it in your Go client source code. For example,

import "github.com/eclipse/paho.mqtt.golang"

Samples are available in the cmd directory for reference.

Note:

The library also supports using MQTT over websockets by using the ws:// (unsecure) or wss:// (secure) prefix in the URI. If the client is running behind a corporate http/https proxy then the following environment variables HTTP_PROXY, HTTPS_PROXY and NO_PROXY are taken into account when establishing the connection.

Runtime tracing

Tracing is enabled by assigning logs (from the Go log package) to the logging endpoints, ERROR, CRITICAL, WARN and DEBUG

Reporting bugs

Please report bugs by raising issues for this project in github https://github.com/eclipse/paho.mqtt.golang/issues

More information

Discussion of the Paho clients takes place on the Eclipse paho-dev mailing list.

General questions about the MQTT protocol are discussed in the MQTT Google Group.

There is much more information available via the MQTT community site.

# Packages

No description provided by the author
No description provided by the author

# Functions

DefaultConnectionLostHandler is a definition of a function that simplyreports to the DEBUG log the reason for the client losing a connection.
NewClient will create an MQTT v3.1.1 client with all of the options specified in the provided ClientOptions.
NewClientOptions will create a new ClientClientOptions type with some default values.
NewFileStore will create a new FileStore which stores its messages in the directory provided.
NewMemoryStore returns a pointer to a new instance of MemoryStore, the instance is not initialized and ready to use until Open() has been called on it.
NewWebsocket returns a new websocket and returns a net.Conn compatible interface using the gorilla/websocket package.

# Constants

Component names for debug output.
Component names for debug output.
Component names for debug output.
Component names for debug output.
Component names for debug output.
Component names for debug output.
Component names for debug output.
Component names for debug output.
Component names for debug output.
Component names for debug output.

# Variables

Internal levels of library output that are initialised to not print anything but can be overridden by programmer.
Internal levels of library output that are initialised to not print anything but can be overridden by programmer.
ErrInvalidQos is the error returned when an packet is to be sentwith an invalid Qos value.
ErrInvalidTopicEmptyString is the error returned when a topic stringis passed in that is 0 length.
ErrInvalidTopicMultilevel is the error returned when a topic stringis passed in that has the multi level wildcard in any position butthe last.
ErrNotConnected is the error returned from function calls that aremade when the client is not connected to a broker.
Internal levels of library output that are initialised to not print anything but can be overridden by programmer.
Internal levels of library output that are initialised to not print anything but can be overridden by programmer.

# Structs

ClientOptions contains configurable options for an Client.
ClientOptionsReader provides an interface for reading ClientOptions after the client has been initialized.
ConnectToken is an extension of Token containing the extra fields required to provide information about calls to Connect().
DisconnectToken is an extension of Token containing the extra fields required to provide information about calls to Disconnect().
No description provided by the author
FileStore implements the store interface using the filesystem to provide true persistence, even across client failure.
MemoryStore implements the store interface to provide a "persistence" mechanism wholly stored in memory.
No description provided by the author
PacketAndToken is a struct that contains both a ControlPacket and a Token.
PlaceHolderToken does nothing and was implemented to allow a messageid to be reserved it differs from DummyToken in that calling flowComplete does not generate an error (it is expected that flowComplete will be called when the token is overwritten with a real token).
PublishToken is an extension of Token containing the extra fields required to provide information about calls to Publish().
SubscribeToken is an extension of Token containing the extra fields required to provide information about calls to Subscribe().
UnsubscribeToken is an extension of Token containing the extra fields required to provide information about calls to Unsubscribe().

# Interfaces

Client is the interface definition for a Client as used by this library, the interface is primarily to allow mocking tests.
No description provided by the author
Message defines the externals that a message implementation must support these are received messages that are passed to the callbacks, not internal messages.
Store is an interface which can be used to provide implementations for message persistence.
Token defines the interface for the tokens used to indicate when actions have completed.
No description provided by the author

# Type aliases

ConnectionLostHandler is a callback type which can be set to be executed upon an unintended disconnection from the MQTT broker.
CredentialsProvider allows the username and password to be updated before reconnecting.
MessageHandler is a callback type which can be set to be executed upon the arrival of messages published to topics to which the client is subscribed.
MId is 16 bit message id as specified by the MQTT spec.
OnConnectHandler is a callback that is called when the client state changes from unconnected/disconnected to connected.
ReconnectHandler is invoked prior to reconnecting after the initial connection is lost.