mqtt

package
v0.0.0-...-c408d52 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// TCP address (<IP>:<port>) that the MQTT will bind to.
	TCPAddress string

	// The size, in bytes, of the MQTT receiver and transmitter buffers.
	BufferSize int

	// The maximum packet size, in bytes, allowed.
	MaxPacketSize int

	// The maximum session expire interval, in seconds, allowed by the server.
	MaxSessionExpiryInterval int

	// The maximum message expiry interval, in seconds.
	MaxMessageExpiryInterval int

	// SysTopicUpdateInterval specifies, in seconds, the interval between $SYS topic updates.
	SysTopicUpdateInterval int

	// The maximum number of outbound message for a client.
	MaxOutboundMessages int

	// The maximum number of topic aliases that an MQTT V5 client is allowed to create.
	MaxTopicAlias int

	// The maximum number of QoS 1 and QoS 2 publications that it is willing to process concurrently.
	ReceiveMaximum int

	// The maximum QoS for PUBLISH Packets accepted by the server.
	MaximumQoS byte

	// The minimum supported MQTT version.
	MinProtocolVersion byte

	// Indicate whether the server allows retained messages or not.
	RetainAvailable bool

	// Indicate whether the server allows wildcard subscription or not.
	WildcardSubscriptionAvailable bool

	// Indicate whether the server allows subscription identifier or not.
	SubscriptionIDAvailable bool

	// Indicate whether the server allows shared subscription or not.
	SharedSubscriptionAvailable bool

	// Indicate whether the server exports metrics or not.
	MetricsEnabled bool
}

Config contains the MQTT Server configuration.

type OptionFn

type OptionFn func(*Server)

OptionFn is a function responsible to inject an option inside the MQTT Server.

func WithConfig

func WithConfig(c *Config) OptionFn

WithConfig is an option function to inject the Config inside the MQTT Server.

func WithLogger

func WithLogger(l *logger.Logger) OptionFn

WithLogger is an option function to inject the logger.Logger inside the MQTT Server.

func WithMachineID

func WithMachineID(id int) OptionFn

WithMachineID is an option function to inject the machine ID inside the MQTT Server.

type Server

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

Server is an MQTT server. It must be created using the NewServer function.

func NewServer

func NewServer(opts ...OptionFn) (*Server, error)

NewServer creates an instance of the MQTT Server. It takes a variable number of OptionFn and returns the Server instance or an error.

func (*Server) Start

func (s *Server) Start() error

Start starts the MQTT Server. In case of failure, it returns the error.

func (*Server) Stop

func (s *Server) Stop()

Stop stops gracefully the MQTT Server.

Jump to

Keyboard shortcuts

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