client

package
v0.0.0-...-b19e04c Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPayloadTooLarge = errors.New("payload is too large")

Functions

This section is empty.

Types

type Client

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

func New

func New(opts Options) *Client

New creates a new client.

func (*Client) DiagnosticArchive

func (c *Client) DiagnosticArchive(_ context.Context, archive types.ArchiveWriter) error

DiagnosticArchive add to a zipfile useful diagnostic information.

func (*Client) Disable

func (c *Client) Disable(until time.Time)

Disable will disable the MQTT connection until given time. To re-enable use ClearDisable().

func (*Client) DisabledUntil

func (c *Client) DisabledUntil() time.Time

func (*Client) Disconnect

func (c *Client) Disconnect(timeout time.Duration)

func (*Client) IsConnectionOpen

func (c *Client) IsConnectionOpen() bool

func (*Client) LastReport

func (c *Client) LastReport() time.Time

LastReport returns the date of last acknowledgment received.

func (*Client) Publish

func (c *Client) Publish(topic string, payload interface{}, retry bool) error

Publish sends the payload to MQTT on the given topic. If retry is set to true and MQTT is currently unreachable, the client will retry to send the message later, else it will be dropped.

func (*Client) Run

func (c *Client) Run(ctx context.Context)

type LogWrapper

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

func GetOrCreateWrapper

func GetOrCreateWrapper() *LogWrapper

func (*LogWrapper) LastPingAt

func (w *LogWrapper) LastPingAt() time.Time

type Options

type Options struct {
	// OptionsFunc returns the options to use when connecting to MQTT.
	OptionsFunc func(ctx context.Context) (*paho.ClientOptions, error)
	// Keep a state between reloads.
	ReloadState types.MQTTReloadState
	// Function called when too many errors happened.
	TooManyErrorsHandler func(ctx context.Context)
	// A unique identifier for this client.
	ID                  string
	PahoLastPingCheckAt func() time.Time
}

type ReloadState

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

ReloadState implements the types.PahoWrapper interface.

func NewReloadState

func NewReloadState() *ReloadState

func (*ReloadState) AddPendingMessage

func (rs *ReloadState) AddPendingMessage(ctx context.Context, m types.Message, shouldWait bool) bool

func (*ReloadState) Client

func (rs *ReloadState) Client() paho.Client

func (*ReloadState) Close

func (rs *ReloadState) Close()

func (*ReloadState) ConnectionLostChannel

func (rs *ReloadState) ConnectionLostChannel() <-chan error

func (*ReloadState) OnConnectionLost

func (rs *ReloadState) OnConnectionLost(_ paho.Client, err error)

func (*ReloadState) PendingMessage

func (rs *ReloadState) PendingMessage(ctx context.Context) (m types.Message, open bool)

func (*ReloadState) PendingMessagesCount

func (rs *ReloadState) PendingMessagesCount() int

func (*ReloadState) SetClient

func (rs *ReloadState) SetClient(cli paho.Client)

Jump to

Keyboard shortcuts

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