internal

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapToUserProperties added in v0.3.0

func MapToUserProperties(m map[string]string) paho.UserProperties

MapToUserProperties converts a map[string]string to userProperties.

func SanitizeString added in v0.3.0

func SanitizeString(input string) string

SanitizeString removes all characters that are not valid in MQTT strings. Since they are otherwise non-printable characters, they are not replaced with any placeholder.

func UserPropertiesToMap added in v0.3.0

func UserPropertiesToMap(ups paho.UserProperties) map[string]string

UserPropertiesToMap converts userProperties to a map[string]string.

Types

type AppendableListWithRemoval added in v0.2.0

type AppendableListWithRemoval[T any] struct {
	// contains filtered or unexported fields
}

func NewAppendableListWithRemoval added in v0.2.0

func NewAppendableListWithRemoval[T any]() *AppendableListWithRemoval[T]

func (*AppendableListWithRemoval[T]) All added in v0.2.0

func (l *AppendableListWithRemoval[T]) All() iter.Seq[T]

func (*AppendableListWithRemoval[T]) AppendEntry added in v0.2.0

func (l *AppendableListWithRemoval[T]) AppendEntry(
	value T,
) (removeEntry func())

type Background added in v0.3.0

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

Background is an abstraction the concept of a long-running backround process, which contexts may need to tie to.

func NewBackground added in v0.3.0

func NewBackground(err error) *Background

func (*Background) Close added in v0.3.0

func (b *Background) Close()

func (*Background) Done added in v0.3.0

func (b *Background) Done() <-chan struct{}

func (*Background) With added in v0.3.0

type ConnectionTracker added in v0.3.0

type ConnectionTracker[Client comparable] struct {
	// contains filtered or unexported fields
}

Struct to track the connection state of the client, and retreive the currently connected client.

func NewConnectionTracker added in v0.3.0

func NewConnectionTracker[Client comparable]() *ConnectionTracker[Client]

func (*ConnectionTracker[Client]) Attempt added in v0.3.0

func (c *ConnectionTracker[Client]) Attempt() uint64

func (*ConnectionTracker[Client]) Client added in v0.3.0

func (c *ConnectionTracker[Client]) Client(
	ctx context.Context,
) iter.Seq2[context.Context, Client]

Return the client for the current connection. Since the client gets replaced when the we reconnect, this is represented as an iterator. The caller should return from the loop once the call they're trying to make is complete, or continue the loop if we need to reconnect and try again. The loop will only terminate on its own via the context. It also provides a context which will be closed if the client disconnects, in order to terminate any requests.

func (*ConnectionTracker[Client]) Connect added in v0.3.0

func (c *ConnectionTracker[Client]) Connect(client Client) error

func (*ConnectionTracker[Client]) Current added in v0.3.0

func (c *ConnectionTracker[Client]) Current() CurrentConnection[Client]

func (*ConnectionTracker[Client]) Disconnect added in v0.3.0

func (c *ConnectionTracker[Client]) Disconnect(attempt uint64, err error)

type CurrentConnection added in v0.3.0

type CurrentConnection[Client comparable] struct {
	// Current instance of the client.
	Client Client

	// Error that caused the last disconnection.
	Error error

	// Background state that is stopped when the the connection is down.
	// Used to notify goroutines that expect the connection to go down that
	// the manageConnection() goroutine has detected the disconnection and
	// is attempting to start a new connection.
	Down *Background

	// Counter for the current connection attempt. This is independent from
	// the client, since it also records unsuccessful connect attempts.
	Attempt uint64
	// contains filtered or unexported fields
}

Mutex-protected connection data.

type Logger added in v0.3.0

type Logger struct{ log.Logger }

func (Logger) Packet added in v0.3.0

func (l Logger) Packet(ctx context.Context, name string, packet any)

Jump to

Keyboard shortcuts

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