utils

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFileMod           os.FileMode = 0o644
	DefaultExecutableFileMod os.FileMode = 0o755
	DefaultDirMod            os.FileMode = 0o755
)
View Source
const DefaultMqttConnectTimeout time.Duration = InitialReconnectInterval

DefaultMqttConnectTimeout bounds a single MQTT connect attempt.

paho.mqtt.golang defaults ConnectTimeout to an implicit 30s. We set our own value so reconnect timing is fully owned by this codebase and stays stable across paho upgrades. The value is intentionally <= the shortest reconnect backoff slot (1.5 * InitialReconnectInterval) so a connect attempt can never outlive the next backoff slot. Endpoints with slow TLS handshakes can raise it per-device via the device config (mqtt_connect_timeout_seconds).

View Source
const InitialReconnectInterval time.Duration = time.Second

InitialReconnectInterval is the base interval the reconnect backoff seeds from. The first reconnect slot produced by ReconnectTimeoutGenerator is therefore ~2x this value (doubled) with up to ±25% jitter, i.e. it is never shorter than 1.5 * InitialReconnectInterval.

Variables

This section is empty.

Functions

func ConfigureLogger

func ConfigureLogger(prefix string, writer io.Writer, level LoggingLevel) hclog.Logger

func NewRequest added in v0.14.0

func NewRequest(method string, url string, body io.Reader) (*http.Request, error)

func NewRequestWithContext added in v0.14.0

func NewRequestWithContext(
	ctx context.Context,
	method string,
	url string,
	body io.Reader,
) (*http.Request, error)

Types

type FileSystem added in v1.0.0

type FileSystem interface {
	Executable() (string, error)
	ReadFile(name string) ([]byte, error)
	WriteFile(name string, data []byte, perm os.FileMode) error
	MkdirAll(path string) error
	RemoveAll(path string) error
}

func NewFileSystem added in v1.0.0

func NewFileSystem() FileSystem

type LoggingLevel added in v0.9.0

type LoggingLevel string
const (
	Trace   LoggingLevel = "trace"
	Debug   LoggingLevel = "debug"
	Info    LoggingLevel = "info"
	Warn    LoggingLevel = "warn"
	Error   LoggingLevel = "error"
	Off     LoggingLevel = "off"
	Default LoggingLevel = ""
)

type ReconnectTimeoutGenerator

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

func (*ReconnectTimeoutGenerator) Clear

func (g *ReconnectTimeoutGenerator) Clear()

func (*ReconnectTimeoutGenerator) Next

func (g *ReconnectTimeoutGenerator) Next()

func (*ReconnectTimeoutGenerator) Timeout added in v0.2.0

Jump to

Keyboard shortcuts

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