VLink  2.0.0
A high-performance communication middleware
vlink::ProxyServer Class Reference

In-process VLink proxy daemon backed by a MessageLoop. More...

#include <proxy_server.h>

Inheritance diagram for vlink::ProxyServer:
Collaboration diagram for vlink::ProxyServer:

Classes

struct  Config
 Construction-time configuration aggregate for ProxyServer. More...
 

Public Member Functions

 ProxyServer (const Config &config)
 Constructs a ProxyServer and brings every proxy subsystem online. More...
 
 ~ProxyServer () override
 Destroys the ProxyServer in a deterministic shutdown order. More...
 
std::string get_token () const
 Returns the authentication token issued by this server. More...
 

Protected Member Functions

size_t get_max_task_count () const override
 Returns the maximum queue depth. More...
 
uint32_t get_max_elapsed_time () const override
 Returns the maximum allowed task execution time in milliseconds. More...
 
void on_begin () override
 Hook invoked once on the loop thread before the first task runs. More...
 
void on_end () override
 Hook invoked once on the loop thread after the last task runs. More...
 

Additional Inherited Members

 Internal queue implementation type. More...
 Back-pressure strategy applied when the bounded queue is at capacity. More...
 Built-in priority levels for kPriorityType loops; higher values dispatch first. More...

Detailed Description

In-process VLink proxy daemon backed by a MessageLoop.

Owns the discovery layer, the handshake/control/time/info DDS channels, the data relay path, and any embedded Iceoryx daemon or runnable plugins. Construction starts the DiscoveryViewer plus its 1-second heartbeat and statistics timers, but it does not start the server's own inherited loop. Call async_run() (or run()) on the MessageLoop base to enable asynchronous relays and the runnable-plugin lifecycle hooks. Only one instance is allowed per process.

Constructor & Destructor Documentation

◆ ProxyServer()

vlink::ProxyServer::ProxyServer ( const Config config)
explicit

Constructs a ProxyServer and brings every proxy subsystem online.

The constructor performs the following steps in order:

  1. Acquires the process-global singleton guard; on contention it logs a fatal message and throws before touching any DDS handle.
  2. Reads the VLINK_INTRA_BIND environment variable.
  3. When config.use_iox is true, calls init_shm_roudi() to spin up an embedded Iceoryx RouDi process.
  4. Calls init_server() to create the handshake, control, time, info, and data channels, subscribe to Control, and start the heartbeat plus statistics timers on the DiscoveryViewer's loop.
  5. Calls init_runnable() to load every plugin listed in config.runnable_list.

The inherited MessageLoop is not started here – call async_run() or run() explicitly when asynchronous relays and plugin lifecycle hooks must run.

Parameters
configServer configuration. See Config for per-field semantics.
Note
A second ProxyServer in the same process is unsupported and the constructor throws.

◆ ~ProxyServer()

vlink::ProxyServer::~ProxyServer ( )
override

Destroys the ProxyServer in a deterministic shutdown order.

Requests the inherited MessageLoop to stop, waits for it, then stops the proxy timers, joins the DiscoveryViewer, and releases each DDS/SHM handle. When the loop has been started, runnable plugins receive on_deinit(), quit(), and wait_for_quit() from on_end() before the destructor drops them. The process-global singleton guard remains set for the rest of the process lifetime.

Member Function Documentation

◆ get_max_elapsed_time()

uint32_t vlink::ProxyServer::get_max_elapsed_time ( ) const
overrideprotectedvirtual

Returns the maximum allowed task execution time in milliseconds.

Tasks exceeding this duration trigger on_task_timeout. Zero disables the check.

Returns
Maximum execution time in milliseconds.

Reimplemented from vlink::MessageLoop.

◆ get_max_task_count()

size_t vlink::ProxyServer::get_max_task_count ( ) const
overrideprotectedvirtual

Returns the maximum queue depth.

Returns
kMaxTaskSize (10000) by default.

Reimplemented from vlink::MessageLoop.

◆ get_token()

std::string vlink::ProxyServer::get_token ( ) const

Returns the authentication token issued by this server.

When VLINK_PROXY_ENABLE_HANDSHAKE is non-zero (the default), the token is generated once at construction via vlink::Uuid::random_hex() and remains constant for the server's lifetime. Clients learn it through the security-authenticated handshake RPC. The server then validates the token on every inbound Control and echoes it (alongside the server identity) inside every Time heartbeat so clients can detect both server restarts and identity mismatches. When the macro is 0, the token is empty, validation is disabled, and the handshake channel is not created.

Returns
Hex-encoded token string, or empty when handshake is compiled out.
Note
Thread-safe; the returned string is a copy.

◆ on_begin()

void vlink::ProxyServer::on_begin ( )
overrideprotectedvirtual

Hook invoked once on the loop thread before the first task runs.

Subclasses override to perform per-thread initialisation.

Reimplemented from vlink::MessageLoop.

◆ on_end()

void vlink::ProxyServer::on_end ( )
overrideprotectedvirtual

Hook invoked once on the loop thread after the last task runs.

Subclasses override to perform per-thread cleanup.

Reimplemented from vlink::MessageLoop.


The documentation for this class was generated from the following file: