|
VLink
2.0.0
A high-performance communication middleware
|
Type-safe RPC handler for the VLink method communication model. More...
#include <server.h>
Public Types | |
| using | UniquePtr = std::unique_ptr< Server< ReqT, RespT, SecT > > |
| Owning unique-pointer alias. More... | |
| using | SharedPtr = std::shared_ptr< Server< ReqT, RespT, SecT > > |
| Owning shared-pointer alias. More... | |
| using | ReqCallback = Function< void(const ReqT &)> |
| Fire-and-forget handler signature. More... | |
| using | ReqRespCallback = Function< void(const ReqT &, RespT &)> |
| Synchronous fill-response handler. More... | |
| using | ReqAsyncRespCallback = Function< void(uint64_t, const ReqT &)> |
| Handler signature for deferred asynchronous replies. More... | |
Public Types inherited from vlink::Node< ServerImpl, SecurityType::kWithoutSecurity > | |
| using | StatusCallback = NodeImpl::StatusCallback |
| Handler signature for status-change notifications. More... | |
Public Member Functions | |
| template<typename ConfT , typename = std::enable_if_t<std::is_base_of_v<Conf, ConfT>>> | |
| Server (const ConfT &conf, InitType type=InitType::kWithInit) | |
| Constructs a server from a typed transport configuration object. More... | |
| Server (const std::string &url_str, InitType type=InitType::kWithInit) | |
| Constructs a server from a URL string. More... | |
| bool | listen (ReqCallback &&callback) |
| Installs a fire-and-forget request handler. More... | |
| bool | listen (ReqRespCallback &&callback) |
| Installs a synchronous request/response handler. More... | |
| bool | listen_for_reply (ReqAsyncRespCallback &&callback) |
Installs a handler that defers the reply via reply(). More... | |
| bool | reply (uint64_t req_id, const RespT &resp) |
| Emits the asynchronous response for a previously received request. More... | |
| template<bool HasPtrT> | |
| bool | reply_bytes (uint64_t req_id, const Bytes &resp_data, bool is_sync, [[maybe_unused]] Bytes *resp_data_ptr) |
Public Member Functions inherited from vlink::Node< ServerImpl, SecurityType::kWithoutSecurity > | |
| virtual bool | init () |
| Initialises the node and its transport back-end. More... | |
| virtual bool | deinit () |
| Tears the node down and releases all transport resources. More... | |
| virtual void | interrupt () |
| Aborts any blocking wait on this node. More... | |
| bool | has_inited () const |
Reports whether init() has been successfully called. More... | |
| bool | is_support_loan () const |
| Reports whether the transport supports zero-copy loaned buffers. More... | |
| Bytes | loan (int64_t size) |
| Allocates a loaned buffer from the transport memory pool. More... | |
| bool | return_loan (const Bytes &bytes) |
| Returns a previously loaned buffer to the transport pool. More... | |
| virtual void | set_manual_unloan (bool manual_unloan) |
| Toggles manual-unloan mode for zero-copy receives. More... | |
| virtual bool | is_manual_unloan () const |
| Reports whether manual-unloan mode is currently active. More... | |
| bool | suspend () |
| Suspends message delivery on this node. More... | |
| bool | resume () |
Resumes message delivery after a prior suspend(). More... | |
| bool | is_suspend () const |
| Reports whether the node is currently suspended. More... | |
| bool | attach (class MessageLoop *message_loop) |
Attaches the node to a MessageLoop for callback dispatch. More... | |
| bool | detach () |
Detaches the node from its current MessageLoop. More... | |
| class MessageLoop * | get_message_loop () const |
Returns the MessageLoop this node is currently attached to. More... | |
| const AbstractNode * | get_abstract_node () const |
| Returns the abstract-graph handle for runtime topology inspection. More... | |
| Status::BasePtr | get_status (Status::Type type) const |
| Retrieves the current status object for the requested category. More... | |
| void | register_status_handler (StatusCallback &&callback) |
| Registers a handler invoked whenever the node's status changes. More... | |
| void | set_property (const std::string &prop, const std::string &value) |
| Sets a transport-specific string-keyed property. More... | |
| std::string | get_property (const std::string &prop) const |
| Retrieves a previously set transport-specific property value. More... | |
| TransportType | get_transport_type () const |
Returns the TransportType this node is bound to. More... | |
| const std::string & | get_url () const |
| Returns the URL string used to construct this node. More... | |
| void | set_record_path (const std::string &path) |
| Enables recording of inbound or outbound messages to a bag file. More... | |
| void | set_ser_type (const std::string &ser_type, SchemaType schema_type=SchemaType::kUnknown) |
| Overrides the runtime wire-metadata identifiers for this node. More... | |
| const std::string & | get_ser_type () const |
| Returns the current concrete runtime type identifier. More... | |
| SchemaType | get_schema_type () const |
| Returns the current coarse schema family. More... | |
| void | set_discovery_enabled (bool enable) |
| Toggles peer-discovery on this node. More... | |
| bool | get_discovery_enabled () const |
| Reports whether peer-discovery is currently enabled. More... | |
| void | bind_proto_arena (void *proto_arena) |
| Binds a Protobuf Arena for arena-allocated message objects. More... | |
| double | get_cpu_usage () const |
| Returns the cumulative CPU-usage ratio sampled by the profiler. More... | |
| bool | get_safety_quit () const |
| Reports whether safe-quit mode is currently active. More... | |
| void | set_safety_quit (bool safety_quit) |
| Enables or disables safe-quit mode. More... | |
| void | set_ssl_options (const SslOptions &options) |
| Configures transport-layer SSL/TLS encryption for this node. More... | |
Static Public Member Functions | |
| static UniquePtr | create_unique (const std::string &url_str, InitType type=InitType::kWithInit) |
Heap-allocates a Server and wraps it in a std::unique_ptr. More... | |
| static SharedPtr | create_shared (const std::string &url_str, InitType type=InitType::kWithInit) |
Heap-allocates a Server and wraps it in a std::shared_ptr. More... | |
Static Public Attributes | |
| static constexpr ImplType | kImplType = kServer |
Node role tag (kServer). More... | |
| static constexpr bool | kHasResp = !std::is_same_v<RespT, Traits::EmptyType> |
true when response produced. More... | |
| static constexpr Serializer::Type | kReqType = Serializer::get_type_of<ReqT>() |
| Codec for the request. More... | |
| static constexpr Serializer::Type | kRespType = Serializer::get_type_of<RespT>() |
| Codec for the response. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from vlink::Node< ServerImpl, SecurityType::kWithoutSecurity > | |
| Node () | |
| virtual | ~Node () |
| bool | enable_security (const Security::Config &cfg) |
Installs a Security configuration before transport initialisation. More... | |
| bool | enable_security (Security::Config &&cfg) |
| Move overload for construction-time security installation. More... | |
| void | invoke_callback (const CallbackT &callback, ArgsT &&... args) |
| TypeT | get_default_value () |
Protected Attributes inherited from vlink::Node< ServerImpl, SecurityType::kWithoutSecurity > | |
| void * | proto_arena_ |
| bool | is_support_loan_ |
| bool | is_manual_unloan_ |
| std::atomic_bool | has_inited_ |
| std::optional< std::mutex > | quit_mtx_ |
| std::unique_ptr< ServerImpl > | impl_ |
Type-safe RPC handler for the VLink method communication model.
Inherits the full Node API and adds handler-side operations: three listen() variants and the deferred reply() entry point. The transport implementation (ServerImpl) is selected by the URL scheme or by the typed configuration object supplied at construction time.
| ReqT | Request message type. Must satisfy Serializer::is_supported(). |
| RespT | Response message type. Defaults to Traits::EmptyType (no response). |
| SecT | Security mode; defaults to SecurityType::kWithoutSecurity. |
| using vlink::Server< ReqT, RespT, SecT >::ReqAsyncRespCallback = Function<void(uint64_t, const ReqT&)> |
Handler signature for deferred asynchronous replies.
Receives the opaque req_id assigned by the framework alongside the incoming request. The handler must eventually call reply(req_id, resp) from any thread to deliver the response.
| using vlink::Server< ReqT, RespT, SecT >::ReqCallback = Function<void(const ReqT&)> |
Fire-and-forget handler signature.
| using vlink::Server< ReqT, RespT, SecT >::ReqRespCallback = Function<void(const ReqT&, RespT&)> |
Synchronous fill-response handler.
| using vlink::Server< ReqT, RespT, SecT >::SharedPtr = std::shared_ptr<Server<ReqT, RespT, SecT> > |
Owning shared-pointer alias.
| using vlink::Server< ReqT, RespT, SecT >::UniquePtr = std::unique_ptr<Server<ReqT, RespT, SecT> > |
Owning unique-pointer alias.
|
inlineexplicit |
Constructs a server from a typed transport configuration object.
Accepts any Conf-derived configuration. A compile-time check enforces that the configuration permits the server role.
| ConfT | Concrete configuration type derived from Conf. |
| conf | Populated configuration aggregate. |
| type | Whether to call init() inline; default is InitType::kWithInit. |
|
inlineexplicit |
Constructs a server from a URL string.
| url_str | Service URL such as "someip://30490/0x1/my_method". |
| type | Whether to call init() inline; default is InitType::kWithInit. |
|
inlinestatic |
Heap-allocates a Server and wraps it in a std::shared_ptr.
| url_str | Service URL string. |
| type | Whether to call init() inline; default is InitType::kWithInit. |
SharedPtr to the new server.
|
inlinestatic |
Heap-allocates a Server and wraps it in a std::unique_ptr.
| url_str | Service URL such as "dds://my_service". |
| type | Whether to call init() inline; default is InitType::kWithInit. |
UniquePtr to the new server.
|
inline |
Installs a fire-and-forget request handler.
Only available when RespT == EmptyType (enforced by static_assert). The handler is invoked for every received request and no response is produced.
| callback | void(const ReqT&) handler. |
true if registration succeeded.
|
inline |
Installs a synchronous request/response handler.
Only available when kHasResp is true. The handler must populate resp before returning; the framework serialises resp immediately and emits the reply on the underlying transport.
| callback | void(const ReqT&, RespT&) handler that fills resp. |
true if registration succeeded.
|
inline |
Installs a handler that defers the reply via reply().
Only available when kHasResp is true. The handler receives an opaque req_id and the deserialised request. The handler must eventually invoke reply(req_id, resp) – from any thread – to send the response back to the waiting client.
| callback | void(uint64_t, const ReqT&) handler. |
true if registration succeeded.
|
inline |
Emits the asynchronous response for a previously received request.
Must be paired with listen_for_reply(); calling reply() after a synchronous listen() triggers a fatal log. The req_id must match the value passed to the async handler. Unknown IDs may be silently rejected by the active transport.
| req_id | Opaque identifier received in the async handler. |
| resp | Response value to serialise and emit. |
true if the transport accepted the response.
|
inline |
|
staticconstexpr |
true when response produced.
|
staticconstexpr |
Node role tag (kServer).
|
staticconstexpr |
Codec for the request.
|
staticconstexpr |
Codec for the response.