VLink  2.3.0
A high-performance communication middleware
vlink::DiscoveryViewer Class Reference

MessageLoop-based aggregator of live VLink endpoint announcements. More...

#include <discovery_viewer.h>

Inheritance diagram for vlink::DiscoveryViewer:
Collaboration diagram for vlink::DiscoveryViewer:

Classes

struct  Info
 One row of the discovery snapshot, describing a URL and its publishers/subscribers. More...
 
struct  Process
 Identity of a process that hosts at least one endpoint for a URL. More...
 

Public Types

enum  FilterType : uint8_t { kFilterNone = 0 , kFilterAvailable = 1 , kFilterNative = 2 }
 Selects which announcements contribute to the live snapshot. More...
 
using Callback = Function< void(const std::vector< Info > &info_list)>
 Callback signature delivered when the snapshot changed since the last tick. More...
 
 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...

Public Member Functions

 DiscoveryViewer (FilterType type=kFilterNone)
 Builds the viewer with the requested filter mode. More...
 
 ~DiscoveryViewer () override
 Stops the viewer loop and releases resources. More...
 
void register_callback (Callback &&callback)
 Registers the callback notified on every snapshot change. More...
 
std::vector< Info > get_info_list ()
 Returns a copy of the live snapshot at the moment of the call. More...
 
std::string get_ser_type (const std::string &url) const
 Resolves the announced serialisation type for url. More...
 
SchemaType get_schema_type (const std::string &url) const
 Resolves the announced coarse schema family for url. More...
 

Static Public Member Functions

static ImplType convert_type (std::string_view str)
 Translates a discovery role token to the corresponding ImplType bit. More...
 
static std::string convert_type_to_view (uint32_t type)
 Formats an ImplType bitmask as a human-readable label. More...
 
static std::string convert_type_to_view (uint32_t type, const std::vector< Process > &process_list)
 Formats an ImplType bitmask together with its process list. More...
 
static uint32_t get_listen_domain ()
 Returns the discovery domain selected by VLINK_DISCOVER_DOMAIN. More...
 
static std::string get_listen_address ()
 Returns the UDP multicast/broadcast address used by the discovery subsystem. More...
 
static uint16_t get_listen_port ()
 Returns the UDP port used by the discovery subsystem. 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...
 
void on_task_timeout (MessageLoop::Callback &&callback, uint32_t elapsed_time) override
 Hook invoked when a task exceeds get_max_elapsed_time(). More...
 

Friends

class DiscoveryReporter
 

Detailed Description

MessageLoop-based aggregator of live VLink endpoint announcements.

Construct with the desired filter and start with async_run(). Each viewer is explicitly owned by the caller; no process-global viewer is exposed. The viewer rebuilds its Info list on demand and notifies the registered callback on its 500 ms tick whenever the snapshot changed since the previous notification.

Member Typedef Documentation

◆ Callback

using vlink::DiscoveryViewer::Callback = Function<void(const std::vector<Info>& info_list)>

Callback signature delivered when the snapshot changed since the last tick.

Invoked on the viewer's MessageLoop thread with the freshly built list; changes are coalesced per 500 ms tick, and a newly registered callback receives its first list on the next tick.

Member Enumeration Documentation

◆ FilterType

Selects which announcements contribute to the live snapshot.

Value Effect
kFilterNone All announcements visible
kFilterAvailable Drop remote announcements for local-only URL schemes
kFilterNative Keep only announcements from the same host
Enumerator
kFilterNone 

No filtering applied.

kFilterAvailable 

Drop remote announcements for local-only URL schemes.

kFilterNative 

Keep only same-host announcements.

Constructor & Destructor Documentation

◆ DiscoveryViewer()

vlink::DiscoveryViewer::DiscoveryViewer ( FilterType  type = kFilterNone)
explicit

Builds the viewer with the requested filter mode.

Parameters
typeFilter selecting which announcements survive (default: kFilterNone).

◆ ~DiscoveryViewer()

vlink::DiscoveryViewer::~DiscoveryViewer ( )
override

Stops the viewer loop and releases resources.

Member Function Documentation

◆ convert_type()

static ImplType vlink::DiscoveryViewer::convert_type ( std::string_view  str)
static

Translates a discovery role token to the corresponding ImplType bit.

Parameters
strRole token: "Ser", "Cli", "Pub", "Sub", "Set" or "Get".
Returns
Matching ImplType, or 0 when the token is not recognised.

◆ convert_type_to_view() [1/2]

static std::string vlink::DiscoveryViewer::convert_type_to_view ( uint32_t  type)
static

Formats an ImplType bitmask as a human-readable label.

Parameters
typeImplType bitmask.
Returns
Display string suitable for tooling output.

◆ convert_type_to_view() [2/2]

static std::string vlink::DiscoveryViewer::convert_type_to_view ( uint32_t  type,
const std::vector< Process > &  process_list 
)
static

Formats an ImplType bitmask together with its process list.

Parameters
typeImplType bitmask.
process_listProcesses to include in the display.
Returns
Combined display string.

◆ get_info_list()

std::vector<Info> vlink::DiscoveryViewer::get_info_list ( )

Returns a copy of the live snapshot at the moment of the call.

Returns
Vector of Info rows.

◆ get_listen_address()

static std::string vlink::DiscoveryViewer::get_listen_address ( )
static

Returns the UDP multicast/broadcast address used by the discovery subsystem.

◆ get_listen_domain()

static uint32_t vlink::DiscoveryViewer::get_listen_domain ( )
static

Returns the discovery domain selected by VLINK_DISCOVER_DOMAIN.

The domain isolates the discovery channel so that unrelated deployments sharing one network never parse each other's announcements. It shifts the UDP port only; the multicast address and its route stay unchanged. Values that are not a plain decimal number or fall outside [0,255] are rejected and fall back to 0, which keeps the historical port; the DiscoveryViewer and DiscoveryReporter constructors log the rejection once. The variable is read once per process, so changing it at runtime has no effect.

Returns
Discovery domain.

◆ get_listen_port()

static uint16_t vlink::DiscoveryViewer::get_listen_port ( )
static

Returns the UDP port used by the discovery subsystem.

Returns
Base port shifted by get_listen_domain().

◆ get_max_elapsed_time()

uint32_t vlink::DiscoveryViewer::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::DiscoveryViewer::get_max_task_count ( ) const
overrideprotectedvirtual

Returns the maximum queue depth.

Returns
kMaxTaskSize (10000) by default.

Reimplemented from vlink::MessageLoop.

◆ get_schema_type()

SchemaType vlink::DiscoveryViewer::get_schema_type ( const std::string &  url) const

Resolves the announced coarse schema family for url.

Parameters
urlTopic URL.
Returns
SchemaType, or SchemaType::kUnknown when unavailable.

◆ get_ser_type()

std::string vlink::DiscoveryViewer::get_ser_type ( const std::string &  url) const

Resolves the announced serialisation type for url.

Parameters
urlTopic URL.
Returns
Announced serialisation type, or an empty string when unknown.

◆ on_begin()

void vlink::DiscoveryViewer::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::DiscoveryViewer::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.

◆ on_task_timeout()

void vlink::DiscoveryViewer::on_task_timeout ( MessageLoop::Callback &&  callback,
uint32_t  elapsed_time 
)
overrideprotectedvirtual

Hook invoked when a task exceeds get_max_elapsed_time().

Parameters
callbackTask that timed out.
elapsed_timeActual execution time in milliseconds.

Reimplemented from vlink::MessageLoop.

◆ register_callback()

void vlink::DiscoveryViewer::register_callback ( Callback &&  callback)

Registers the callback notified on every snapshot change.

Replaces any previously installed callback; only the most recent registration remains effective.

Parameters
callbackFunction invoked with the new Info list.

Friends And Related Function Documentation

◆ DiscoveryReporter

friend class DiscoveryReporter
friend

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