38template <
typename ImplT, SecurityType SecT>
40 bool expected =
false;
56template <
typename ImplT, SecurityType SecT>
67 std::lock_guard quit_lock(
quit_mtx_.value());
78template <
typename ImplT, SecurityType SecT>
83template <
typename ImplT, SecurityType SecT>
85 return impl_->is_support_loan();
88template <
typename ImplT, SecurityType SecT>
95template <
typename ImplT, SecurityType SecT>
97 return impl_->return_loan(bytes);
100template <
typename ImplT, SecurityType SecT>
103 VLOG_W(
"Node: Function [set_manual_unloan] is not supported.");
106template <
typename ImplT, SecurityType SecT>
111template <
typename ImplT, SecurityType SecT>
113 return impl_->suspend();
116template <
typename ImplT, SecurityType SecT>
118 return impl_->resume();
121template <
typename ImplT, SecurityType SecT>
123 return impl_->is_suspend();
126template <
typename ImplT, SecurityType SecT>
128 return impl_->attach(message_loop);
131template <
typename ImplT, SecurityType SecT>
133 return impl_->detach();
136template <
typename ImplT, SecurityType SecT>
138 return impl_->get_message_loop();
141template <
typename ImplT, SecurityType SecT>
143 return impl_->interrupt();
146template <
typename ImplT, SecurityType SecT>
148 return impl_->get_abstract_node();
151template <
typename ImplT, SecurityType SecT>
153 return impl_->get_status(type);
156template <
typename ImplT, SecurityType SecT>
158 impl_->register_status_handler(std::move(callback));
161template <
typename ImplT, SecurityType SecT>
163 impl_->set_property(prop, value);
166template <
typename ImplT, SecurityType SecT>
168 return impl_->get_property(prop);
171template <
typename ImplT, SecurityType SecT>
173 return impl_->transport_type;
176template <
typename ImplT, SecurityType SecT>
181template <
typename ImplT, SecurityType SecT>
187 VLOG_F(
"Node: Intra or Dds(cdr) type does not support security.");
190 security_->set_key(key);
193template <
typename ImplT, SecurityType SecT>
197 VLOG_F(
"Node: Intra or Dds(cdr) type does not support record.");
203template <
typename ImplT, SecurityType SecT>
208 security_->set_callbacks(std::move(encrypt_callback), std::move(decrypt_callback));
211template <
typename ImplT, SecurityType SecT>
213 auto next_schema_type =
impl_->schema_type;
215 if (ser_type.empty()) {
218 next_schema_type = schema_type;
223 next_schema_type = inferred_schema_type;
229 const bool ser_changed = impl_->ser_type != ser_type;
230 const bool schema_changed = impl_->schema_type != next_schema_type;
232 if VLIKELY (!ser_changed && !schema_changed) {
236 if VUNLIKELY (ser_changed && !impl_->ser_type.empty() && !ser_type.empty()) {
237 CLOG_W(
"Node: Enforce serialization type [%s] => [%s].", impl_->ser_type.c_str(), ser_type.c_str());
242 CLOG_W(
"Node: Enforce schema type [%d] => [%d].",
static_cast<int>(impl_->schema_type),
243 static_cast<int>(next_schema_type));
251 impl_->schema_type = next_schema_type;
258template <
typename ImplT, SecurityType SecT>
260 return impl_->ser_type;
263template <
typename ImplT, SecurityType SecT>
265 return impl_->schema_type;
268template <
typename ImplT, SecurityType SecT>
272 impl_->set_discovery_enabled(enable);
275 impl_->set_discovery_enabled(enable);
279template <
typename ImplT, SecurityType SecT>
281 return impl_->get_discovery_enabled();
284template <
typename ImplT, SecurityType SecT>
289template <
typename ImplT, SecurityType SecT>
291 if (
impl_->profiler) {
292 return impl_->profiler->get();
298template <
typename ImplT, SecurityType SecT>
303template <
typename ImplT, SecurityType SecT>
316template <
typename ImplT, SecurityType SecT>
318 impl_->set_ssl_options(options);
321template <
typename ImplT, SecurityType SecT>
323 static_assert(std::is_base_of_v<NodeImpl, ImplT>,
"ImplT must be derived from NodeImpl.");
326template <
typename ImplT, SecurityType SecT>
331template <
typename ImplT, SecurityType SecT>
337 VLOG_F(
"Node: Intra or Dds(cdr) type does not support security.");
343template <
typename ImplT, SecurityType SecT>
344template <
typename CallbackT,
typename... ArgsT>
347 std::lock_guard quit_lock(
quit_mtx_.value());
348 std::invoke(callback, std::forward<ArgsT>(args)...);
350 std::invoke(callback, std::forward<ArgsT>(args)...);
354template <
typename ImplT, SecurityType SecT>
355template <
typename TypeT>
358 return std::make_shared<typename TypeT::element_type>();
365 VLOG_F(
"Node: Proto arena is not bound, url: ", this->
impl_->url,
".");
368 }
else if constexpr (std::is_default_constructible_v<TypeT>) {
Minimal interface for accessing the underlying native transport handle.
Definition node_impl.h:96
Versatile 128-byte byte buffer with SBO, five ownership modes and compression helpers.
Definition bytes.h:113
Single-threaded serial task dispatcher with integrated timer support.
Definition message_loop.h:106
void set_property(const std::string &prop, const std::string &value)
Sets a transport-specific key-value property on the node.
Definition node-inl.h:162
void set_ser_type(const std::string &ser_type, SchemaType schema_type=SchemaType::kUnknown)
Overrides the runtime wire metadata for this node.
Definition node-inl.h:212
bool attach(class MessageLoop *message_loop)
Attaches the node to a MessageLoop for callback dispatching.
Definition node-inl.h:127
SchemaType get_schema_type() const
Returns the current coarse schema family.
Definition node-inl.h:264
virtual void interrupt()
Unblocks any active blocking wait on this node.
Definition node-inl.h:142
bool has_inited() const
Returns true if init() has been successfully called.
Definition node-inl.h:79
bool resume()
Resumes message delivery after a suspend().
Definition node-inl.h:117
const std::string & get_ser_type() const
Returns the current serialisation type string.
Definition node-inl.h:259
std::unique_ptr< ImplT > impl_
Definition node.h:558
void invoke_callback(const CallbackT &callback, ArgsT &&... args)
Definition node-inl.h:345
void set_safety_quit(bool safety_quit)
Enables or disables safe-quit mode.
Definition node-inl.h:304
bool is_support_loan() const
Returns true if the transport supports zero-copy loaned buffers.
Definition node-inl.h:84
bool get_discovery_enabled() const
Returns true if peer-discovery is currently enabled.
Definition node-inl.h:280
bool suspend()
Suspends message delivery on this node.
Definition node-inl.h:112
virtual bool init()
Initialises the node and its transport back-end.
Definition node-inl.h:39
std::optional< std::mutex > quit_mtx_
Definition node.h:560
void set_record_path(const std::string &path)
Sets the filesystem path for message bag recording.
Definition node-inl.h:194
void register_status_handler(StatusCallback &&callback)
Registers a handler called when the node's status changes.
Definition node-inl.h:157
bool is_suspend() const
Returns true if the node is currently suspended.
Definition node-inl.h:122
bool is_support_loan_
Definition node.h:562
virtual void set_manual_unloan(bool manual_unloan)
Enables or disables manual-unloan mode for zero-copy receives.
Definition node-inl.h:101
virtual bool deinit()
Shuts down the node and releases all transport resources.
Definition node-inl.h:57
std::optional< Security > security_
Definition node.h:559
const std::string & get_url() const
Returns the URL string used to construct this node.
Definition node-inl.h:177
virtual ~Node()
Definition node-inl.h:327
void bind_proto_arena(void *proto_arena)
Binds a Protobuf Arena for arena-allocated message objects.
Definition node-inl.h:285
bool get_safety_quit() const
Returns true if safe-quit mode is currently active.
Definition node-inl.h:299
TypeT get_default_value()
Definition node-inl.h:356
bool is_manual_unloan_
Definition node.h:563
std::atomic_bool has_inited_
Definition node.h:556
void set_security_callbacks(Security::Callback &&encrypt_callback, Security::Callback &&decrypt_callback)
Installs custom encrypt and decrypt callbacks.
Definition node-inl.h:204
virtual bool is_manual_unloan() const
Returns true if manual-unloan mode is active.
Definition node-inl.h:107
class MessageLoop * get_message_loop() const
Returns the MessageLoop this node is attached to.
Definition node-inl.h:137
Bytes loan(int64_t size)
Allocates a loaned buffer from the transport memory pool.
Definition node-inl.h:89
void * proto_arena_
Definition node.h:561
const AbstractNode * get_abstract_node() const
Returns the abstract node handle for graph introspection.
Definition node-inl.h:147
void set_security_key(const std::string &key)
Sets the symmetric encryption key for message security.
Definition node-inl.h:182
double get_cpu_usage() const
Returns the cumulative CPU usage ratio for this node.
Definition node-inl.h:290
bool detach()
Detaches the node from its current MessageLoop.
Definition node-inl.h:132
std::string get_property(const std::string &prop) const
Retrieves a transport-specific property value.
Definition node-inl.h:167
Status::BasePtr get_status(Status::Type type) const
Returns the current status object for the specified status type.
Definition node-inl.h:152
TransportType get_transport_type() const
Returns the TransportType of the transport this node is bound to.
Definition node-inl.h:172
void set_discovery_enabled(bool enable)
Enables or disables peer-discovery on this node.
Definition node-inl.h:269
bool return_loan(const Bytes &bytes)
Returns a previously loaned buffer back to the transport pool.
Definition node-inl.h:96
NodeImpl::StatusCallback StatusCallback
Callback type for node status-change notifications.
Definition node.h:128
void enable_security()
Definition node-inl.h:332
Node()
Definition node-inl.h:322
void set_ssl_options(const SslOptions &options)
Configures transport-layer SSL/TLS encryption for this node.
Definition node-inl.h:317
std::function< bool(const Bytes &in, Bytes &out)> Callback
Callback type for custom encryption or decryption.
Definition security.h:94
Global singleton logger with three output styles and pluggable backends.
#define VLOG_F(...)
Definition logger.h:856
#define VLOG_W(...)
Definition logger.h:852
#define CLOG_W(...)
Definition logger.h:864
#define VUNLIKELY(...)
Shorthand alias for VLINK_UNLIKELY. Hints that the expression is unlikely true.
Definition macros.h:302
#define VLIKELY(...)
Shorthand alias for VLINK_LIKELY. Hints that the expression is likely true.
Definition macros.h:297
constexpr bool is_proto_ptr_type() noexcept
Returns true if T is a raw pointer to a Protobuf message.
Definition serializer-inl.h:664
Type
Discriminator for concrete status event types.
Definition status.h:97
std::shared_ptr< Status::Base > BasePtr
Type alias for a shared pointer to a base status event.
Definition status.h:241
SchemaType
Coarse runtime schema family used by discovery, bag metadata, and proxy routing.
Definition types.h:184
@ kUnknown
Decode category is not known.
Definition types.h:185
@ kZeroCopy
Decode using VLink zero-copy message structs.
Definition types.h:187
@ kRaw
Treat the payload as opaque/raw bytes.
Definition types.h:186
TransportType
Enumeration of all supported transport backends.
Definition types.h:107
@ kDds
Fast-DDS RTPS (dds://).
Definition types.h:113
@ kIntra
In-process queue (intra://).
Definition types.h:109
@ kWithSecurity
Encrypted and authenticated transport.
Definition types.h:150
Base CRTP template for all VLink communication nodes.
Definition serializer-inl.h:97
static T * Create(Arena *)
Definition serializer-inl.h:99
static constexpr SchemaType infer_ser_type(std::string_view ser_type) noexcept
Infers a coarse schema family directly from a concrete ser_type string.
Definition types.h:400
static bool is_real_type(SchemaType schema_type) noexcept
Returns whether a schema type carries concrete runtime schema metadata.
static bool is_valid_type(SchemaType schema_type) noexcept
Returns whether a schema type enum value is within the supported range.
Aggregate of SSL/TLS settings for transport-layer encryption.
Definition ssl_options.h:119
A type trait that always evaluates to std::false_type.
Definition traits.h:109
Detects whether type T is a std::shared_ptr specialization.
Definition traits.h:224
Semantic version number with comparison and string conversion utilities.
Definition types.h:329
Core type definitions shared across all VLink node implementations.
VLink library version constants, build-time feature flags, and version comparison macros.
#define VLINK_VERSION_PATCH
Definition version.h:57
#define VLINK_VERSION_MAJOR
Definition version.h:55
#define VLINK_VERSION_MINOR
Definition version.h:56