transport

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package transport is the protocol-level abstraction for network resources the engine talks to. Mirrors driver/, but at a different lifecycle scope: drivers come from the device manifest at engine boot, transports come from deploy config per deploy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MQTTMessage

type MQTTMessage struct {
	Topic   string
	Payload []byte
}

MQTTMessage is one message delivered by an MQTT subscription.

type MQTTTransport

type MQTTTransport interface {
	Transport
	// Publish sends payload to topic.
	Publish(topic string, payload []byte, qos byte, retain bool) error
	// Subscribe returns a buffered channel of messages matching filter. Each
	// call creates a separate subscription with its own channel; sends are
	// non-blocking and drop on full so a slow subscriber can never stall the
	// paho receive loop.
	Subscribe(filter string, qos byte) (<-chan MQTTMessage, error)
}

MQTTTransport multiplexes one TCP connection across many topics.

func OpenMQTT

func OpenMQTT(brokerURL, clientID, username, password string, will *engine.MQTTWill) (MQTTTransport, error)

OpenMQTT establishes a connection to the broker and returns an MQTTTransport. Connect blocks up to mqttOpTimeout; on failure no resources are leaked.

type Registry

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

Registry holds the per-deploy MQTT transport instances, keyed by network ID. Constructed fresh for each deploy via the engine's deploy plumbing; closed and replaced on the next deploy. Mirrors driver.Registry's open-on-construct + close-on-partial-fail discipline.

func NewRegistry

func NewRegistry(ext *engine.ExternalResources) (*Registry, error)

NewRegistry opens every MQTT transport in the deploy's external resources, keyed by external resource id. On any failure transports opened so far are closed.

func (*Registry) CloseAll

func (r *Registry) CloseAll() error

CloseAll shuts down every transport. Returns the first error encountered; keeps going on failures so no connection leaks.

func (*Registry) MQTT

func (r *Registry) MQTT(networkID string) (MQTTTransport, error)

MQTT returns the transport registered under networkID, or an error if no such network was opened in this deploy.

type Transport

type Transport interface {
	Close() error // Close releases the connection and any associated resources.
}

Transport is the base contract for protocol handles.

Jump to

Keyboard shortcuts

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