|
VLink 2.0.0
A high-performance communication middleware
|
Transport-agnostic base for client (RPC caller) node implementations. More...
#include <client_impl.h>
Public Member Functions | |
| ~ClientImpl () override | |
| Destructor. | |
| void | interrupt () override |
Interrupts the client, waking any blocked wait_for_connected() or call() operation. | |
| virtual void | detect_connected (ConnectCallback &&callback) |
| Registers a callback to be fired when the server connection state changes. | |
| virtual bool | wait_for_connected (std::chrono::milliseconds timeout) |
| Blocks until the server is reachable or the timeout elapses. | |
| virtual bool | is_connected () const =0 |
Returns true when the transport is connected to a server. | |
| virtual bool | call (const Bytes &req_data, MsgCallback &&callback, std::chrono::milliseconds timeout)=0 |
| Sends a request and blocks until the response arrives or the timeout elapses. | |
| void | update_connected () |
| Notifies the connection-detection subsystem that connectivity may have changed. | |
| Public Member Functions inherited from vlink::NodeImpl | |
| virtual void | init ()=0 |
| Initialises the underlying transport channel. | |
| virtual void | deinit ()=0 |
| Tears down the underlying transport channel. | |
| virtual bool | suspend () |
| Temporarily suspends message delivery without tearing down the channel. | |
| virtual bool | resume () |
Resumes message delivery after a suspend() call. | |
| virtual bool | is_suspend () const |
Returns true when the node is currently suspended. | |
| virtual bool | is_support_loan () const |
Returns true if the transport supports zero-copy loaning. | |
| virtual Bytes | loan (int64_t size) |
Borrows a write buffer of size bytes from the transport. | |
| virtual bool | return_loan (const Bytes &bytes) |
| Returns a previously loaned buffer to the transport. | |
| virtual void | set_manual_unloan (bool manual_unloan) |
| Configures manual unloan mode for zero-copy transports. | |
| virtual const struct Conf * | get_conf () const |
Returns a pointer to the associated Conf configuration object. | |
| virtual const AbstractNode * | get_abstract_node () const |
Returns a pointer to the AbstractNode peer (if any). | |
| virtual Status::BasePtr | get_status (Status::Type type) const |
| Retrieves a transport-specific status object. | |
| virtual bool | check_version (const Version &version) |
Checks whether version matches the runtime VLink library version. | |
| virtual bool | attach (class MessageLoop *message_loop) |
Attaches the node to a MessageLoop for callback dispatch. | |
| virtual bool | detach () |
Detaches the node from its MessageLoop. | |
| class MessageLoop * | get_message_loop () const |
Returns the MessageLoop this node is attached to. | |
| template<typename T> | |
| const T * | get_target_conf () const |
Returns a typed pointer to the conf by downcasting to T. | |
| void | register_status_handler (StatusCallback &&callback) |
| Registers a callback for DDS status events. | |
| bool | has_register_status () const |
Returns true if a status handler has been registered. | |
| void | call_status (Status::BasePtr ptr) |
| Dispatches a status event to the registered status handler. | |
| void | set_property (const std::string &prop, const std::string &value) |
| Sets a named transport property on this node. | |
| std::string | get_property (const std::string &prop) const |
| Retrieves a named transport property. | |
| Conf::PropertiesMap | get_all_properties () const |
| Returns a snapshot of all properties set on this node. | |
| void | set_discovery_enabled (bool enable) |
| Enables or disables discovery reporting for this node. | |
| bool | get_discovery_enabled () const |
Returns true if discovery reporting is enabled for this node. | |
| void | set_record_path (const std::string &path) |
| Sets the file path for per-node message recording. | |
| void | set_ssl_options (const SslOptions &options) |
| Merges SSL/TLS options into the node property map. | |
| void | try_record (ActionType action_type, const Bytes &data) |
| Records a message to the global and/or per-node bag writers. | |
| void | reset_interrupted () |
Clears the interrupted flag set by interrupt(). | |
| bool | is_interrupted () const |
Returns true if interrupt() has been called and not yet reset. | |
| void | init_ext () |
Registers the node with the global DiscoveryReporter. | |
| void | deinit_ext () |
Deregisters the node from the global DiscoveryReporter. | |
Public Attributes | |
| bool | is_resp_type {false} |
true when the call expects a response (vs fire-and-forget). | |
| Public Attributes inherited from vlink::NodeImpl | |
| std::atomic_bool | has_suspend {false} |
| Atomic suspend state flag (currently unused by default impls). | |
| std::string | url |
Full URL string of this node (e.g. "dds://my/topic"). | |
| std::string | ser_type |
Serialisation type string (e.g. "demo.proto.PointCloud"). | |
| ImplType | impl_type {kUnknownImplType} |
| Role of this implementation node. | |
| SchemaType | schema_type {SchemaType::kUnknown} |
| Coarse schema family reported to discovery and bag/proxy paths. | |
| TransportType | transport_type {TransportType::kUnknown} |
| Transport backend of this implementation node. | |
| bool | is_cdr_type {false} |
true when using DDS native CDR serialisation. | |
| bool | is_security_type {false} |
true when security-authenticated transport is enabled. | |
| bool | is_discovery_enabled {true} |
| Whether this node is reported to the discovery layer. | |
| std::unique_ptr< class CpuProfiler > | profiler |
| Optional per-node CPU profiler (only when global profiling is on). | |
Protected Member Functions | |
| ClientImpl () | |
Protected constructor; initialises the client with kClient role. | |
| Protected Member Functions inherited from vlink::NodeImpl | |
| NodeImpl (ImplType type) | |
| virtual | ~NodeImpl () |
Additional Inherited Members | |
| Public Types inherited from vlink::NodeImpl | |
| using | ConnectCallback = std::function<void(bool)> |
| Callback invoked when the peer connection state changes. | |
| using | StatusCallback = std::function<void(const Status::BasePtr& ptr)> |
| Callback invoked on DDS status events (e.g. deadline missed). | |
| using | SyncCallback = std::function<void()> |
Callback invoked when a SetterImpl sync completes. | |
| using | ReqRespCallback = std::function<void(uint64_t, const Bytes&, Bytes*)> |
Callback for ServerImpl request/response processing. | |
| using | MsgCallback = std::function<void(const Bytes&)> |
Callback delivering a raw serialised message to a SubscriberImpl or GetterImpl. | |
| using | IntraMsgCallback = std::function<void(const IntraData&)> |
Callback delivering an in-process IntraData message. | |
| Static Public Member Functions inherited from vlink::NodeImpl | |
| static void | global_init () |
| Initialises process-wide VLink singletons. | |
Transport-agnostic base for client (RPC caller) node implementations.
Provides the server-connection-detection infrastructure (condition variable + callback) used by Client<Req,Resp>::wait_for_connected() and Client<Req,Resp>::detect_connected(). Concrete backends override is_connected() to query the transport layer and call update_connected() whenever the server connection state changes.
|
override |
Destructor.
|
protected |
Protected constructor; initialises the client with kClient role.
|
pure virtual |
Sends a request and blocks until the response arrives or the timeout elapses.
Must be implemented by each concrete transport backend. req_data contains the serialised request payload. The callback is invoked with the response bytes once the round-trip completes.
| req_data | Serialised request payload. |
| callback | Callable void(const Bytes&) invoked with the response bytes. |
| timeout | Maximum time to wait for the response; negative = infinite. |
true if a response was received within the timeout; false on timeout, interruption, or transport error.
|
virtual |
Registers a callback to be fired when the server connection state changes.
The callback is stored and invoked with true when the server becomes reachable and false when it disconnects. If the server is already connected at registration time the callback is fired immediately with true before this function returns.
| callback | Callable void(bool) to invoke on connection state change. |
|
overridevirtual |
Interrupts the client, waking any blocked wait_for_connected() or call() operation.
Calls NodeImpl::interrupt() to set the interrupted flag, then notify_all() on the internal condition variable so that any thread blocked in wait_for_connected() returns immediately. Concrete backends typically also forward the interrupt to any pending AckManager requests.
Reimplemented from vlink::NodeImpl.
|
nodiscardpure virtual |
Returns true when the transport is connected to a server.
Must be implemented by each concrete transport backend. Called by wait_for_connected() and update_connected() to determine whether the connection state has changed.
true if a server is reachable; false otherwise. | void vlink::ClientImpl::update_connected | ( | ) |
Notifies the connection-detection subsystem that connectivity may have changed.
Called by the concrete transport backend whenever a server connects or disconnects. Compares the current is_connected() result against the cached state; if it differs, the condition variable is notified and the registered ConnectCallback is fired.
|
virtual |
Blocks until the server is reachable or the timeout elapses.
Returns immediately if is_connected() is already true. Otherwise waits on an internal condition variable that is notified by update_connected() and interrupt().
timeout < 0 (e.g. Timeout::kInfinite): waits indefinitely.timeout >= 0: returns false if no server appears within the period.| timeout | Maximum time to wait; negative value means wait forever. |
true if the server was detected; false on timeout or interruption. | bool vlink::ClientImpl::is_resp_type {false} |
true when the call expects a response (vs fire-and-forget).