VLink  2.3.0
A high-performance communication middleware
vlink::DiscoveryViewer类 参考

MessageLoop-based aggregator of live VLink endpoint announcements. 更多...

#include <discovery_viewer.h>

类 vlink::DiscoveryViewer 继承关系图:
vlink::DiscoveryViewer 的协作图:

类

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

Public 类型

enum  FilterType : uint8_t { kFilterNone = 0 , kFilterAvailable = 1 , kFilterNative = 2 }
 Selects which announcements contribute to the live snapshot. 更多...
 
using Callback = Function< void(const std::vector< Info > &info_list)>
 Callback signature delivered when the snapshot changed since the last tick. 更多...
 
 Internal queue implementation type. 更多...
 Back-pressure strategy applied when the bounded queue is at capacity. 更多...
 Built-in priority levels for kPriorityType loops; higher values dispatch first. 更多...

Public 成员函数

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

静态 Public 成员函数

static ImplType convert_type (std::string_view str)
 Translates a discovery role token to the corresponding ImplType bit. 更多...
 
static std::string convert_type_to_view (uint32_t type)
 Formats an ImplType bitmask as a human-readable label. 更多...
 
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. 更多...
 
static uint32_t get_listen_domain ()
 Returns the discovery domain selected by VLINK_DISCOVER_DOMAIN. 更多...
 
static std::string get_listen_address ()
 Returns the UDP multicast/broadcast address used by the discovery subsystem. 更多...
 
static uint16_t get_listen_port ()
 Returns the UDP port used by the discovery subsystem. 更多...
 

Protected 成员函数

size_t get_max_task_count () const override
 Returns the maximum queue depth. 更多...
 
uint32_t get_max_elapsed_time () const override
 Returns the maximum allowed task execution time in milliseconds. 更多...
 
void on_begin () override
 Hook invoked once on the loop thread before the first task runs. 更多...
 
void on_end () override
 Hook invoked once on the loop thread after the last task runs. 更多...
 
void on_task_timeout (MessageLoop::Callback &&callback, uint32_t elapsed_time) override
 Hook invoked when a task exceeds get_max_elapsed_time(). 更多...
 

友元

class DiscoveryReporter
 

详细描述

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.

成员类型定义说明

◆ 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.

成员枚举类型说明

◆ 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
枚举值
kFilterNone 

No filtering applied.

kFilterAvailable 

Drop remote announcements for local-only URL schemes.

kFilterNative 

Keep only same-host announcements.

构造及析构函数说明

◆ DiscoveryViewer()

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

Builds the viewer with the requested filter mode.

参数
typeFilter selecting which announcements survive (default: kFilterNone).

◆ ~DiscoveryViewer()

vlink::DiscoveryViewer::~DiscoveryViewer ( )
override

Stops the viewer loop and releases resources.

成员函数说明

◆ convert_type()

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

Translates a discovery role token to the corresponding ImplType bit.

参数
strRole token: "Ser", "Cli", "Pub", "Sub", "Set" or "Get".
返回
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.

参数
typeImplType bitmask.
返回
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.

参数
typeImplType bitmask.
process_listProcesses to include in the display.
返回
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.

返回
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.

返回
Discovery domain.

◆ get_listen_port()

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

Returns the UDP port used by the discovery subsystem.

返回
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.

返回
Maximum execution time in milliseconds.

重载 vlink::MessageLoop .

◆ get_max_task_count()

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

Returns the maximum queue depth.

返回
kMaxTaskSize (10000) by default.

重载 vlink::MessageLoop .

◆ get_schema_type()

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

Resolves the announced coarse schema family for url.

参数
urlTopic URL.
返回
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.

参数
urlTopic URL.
返回
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.

重载 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.

重载 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().

参数
callbackTask that timed out.
elapsed_timeActual execution time in milliseconds.

重载 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.

参数
callbackFunction invoked with the new Info list.

友元及相关函数文档

◆ DiscoveryReporter

friend class DiscoveryReporter
friend

该类的文档由以下文件生成: