Class SubscriptionTransportProvider

Inheritance Relationships

Derived Type

Class Documentation

class SubscriptionTransportProvider

Virtual interface for pluggable subscription transport protocols.

SSE is the built-in default (SOVD-compliant). Non-SSE protocols (MQTT, WebSocket, Zenoh) are vendor extensions.

Subclassed by ros2_medkit_gateway::SseTransportProvider

Public Functions

virtual ~SubscriptionTransportProvider() = default
virtual std::string protocol() const = 0

Protocol identifier: “sse” (standard), or vendor extension.

virtual tl::expected<std::string, std::string> start(const CyclicSubscriptionInfo &info, ResourceSamplerFn json_sampler, GatewayNode *node) = 0

Start delivery for a subscription. Returns event_source URI for client.

virtual void notify_update(const std::string &sub_id) = 0

Subscription interval/duration changed. Transport must re-read info.

virtual void stop(const std::string &sub_id) = 0

Stop delivery for a subscription.

For HTTP-based transports (SSE), the HTTP server thread join handles synchronous stop - stop() removes state so the streaming loop exits on its next is_active() check. GatewayNode::~GatewayNode() calls stop_rest_server() before shutdown_all() to ensure this ordering.

Non-HTTP transports MUST ensure all delivery threads have stopped before returning from this method.

inline virtual tl::expected<http::SseStream, ErrorInfo> make_sse_stream(const std::string &sub_id)

Open a new client stream for the given subscription. HTTP-based transports (SSE) build an whose next_event callback the typed router drives via cpp-httplib’s chunked content provider. Non-HTTP transports (MQTT, WebSocket, Zenoh) return an ErrorInfo so the typed handler renders a SOVD GenericError.

On failure (unknown sub_id, client-limit exhausted, …) the implementation returns a fully-formed ErrorInfo whose http_status drives the wire status code. On success the returned SseStream’s lifetime owns the transport-side client-tracker handle (e.g. via a shared_ptr deleter on a captured tracker token) so the slot is released when the framework destroys the stream - either on client disconnect or end-of-stream.