OGLplus  (0.59.0) a C++ wrapper for rendering APIs

Message bus client endpoint that can send and receive messages. More...

#include <eagine/message_bus/endpoint.hpp>

Public Types

using fetch_handler = connection::fetch_handler
 Alias for message fetch handler callable reference.
 
using blob_filter_function = blob_manipulator::filter_function
 Alias for blob message type filter callable reference.
 
using method_handler = callable_ref< bool(const message_context &, stored_message &)>
 Alias for callable handling received messages. More...
 
- Public Types inherited from eagine::named_logging_object< main_ctx_log_backend_getter >
using entry_type = std::conditional_t< is_log_level_enabled_v< severity >, log_entry, no_log_entry >
 The entry type for the specified log_event_severity. More...
 
- Public Types inherited from eagine::basic_logger< main_ctx_log_backend_getter >
using entry_type = std::conditional_t< is_log_level_enabled_v< severity >, log_entry, no_log_entry >
 The entry type for the specified log_event_severity. More...
 

Public Member Functions

 endpoint (main_ctx_object obj) noexcept
 Construction with a reference to parent main context object.
 
 endpoint (identifier id, main_ctx_parent parent) noexcept
 Construction with an enpoint id and parent main context object.
 
 endpoint (const endpoint &)=delete
 Not copy constructible.
 
auto operator= (endpoint &&)=delete
 Not move assignable.
 
auto operator= (const endpoint &)=delete
 Not copy assignable.
 
auto ctx () noexcept -> context &
 Returns a reference to the message bus context. More...
 
auto set_id (identifier id) -> auto &
 Assigns the unique id of this endpoint. More...
 
auto preconfigure_id (identifier_t id) -> auto &
 Preconfigures the unique id of this endpoint. More...
 
auto has_preconfigured_id () const noexcept -> bool
 Indicates if this endpoint has a preconfigured id (or should request one). More...
 
auto has_id () const noexcept -> bool
 Indicates if this endpoint has valid id (set manually or from the bus). More...
 
auto get_preconfigured_id () const noexcept
 Returns the preconfigured id of this endpoint. More...
 
auto get_id () const noexcept
 Returns the unique id of this endpoint. More...
 
void add_certificate_pem (memory::const_block blk)
 Adds endpoint certificate in a PEM-encoded memory block. More...
 
void add_ca_certificate_pem (memory::const_block blk)
 Adds CA certificate in a PEM-encoded memory block. More...
 
auto add_connection (std::unique_ptr< connection > conn) -> bool final
 Adds a connection for communication with a message bus router.
 
auto is_usable () const -> bool
 Tests if this has all prerequisites for sending and receiving messages.
 
auto max_data_size () const -> valid_if_positive< span_size_t >
 Returns the maximum data block size that the endpoint can send.
 
void flush_outbox ()
 Sends any pending outgoing messages if possible.
 
auto update () -> bool
 Updates the internal state, sends and receives pending messages.
 
void finish ()
 Says to the message bus that this endpoint is disconnecting.
 
void subscribe (message_id)
 Subscribes to messages with the specified id/type.
 
void unsubscribe (message_id)
 Unsubscribes from messages with the specified id/type.
 
auto post (message_id msg_id, message_view message) -> bool
 Enqueues a message with the specified id/type for sending. More...
 
auto post_signed (message_id, message_view message) -> bool
 Signs and enqueues a message with the specified id/type for sending. More...
 
template<typename T >
auto post_value (message_id msg_id, T &value, const message_info &info={}) -> bool
 Serializes the specified value and enqueues it for sending in message. More...
 
auto post_blob (message_id msg_id, identifier_t target_id, memory::const_block blob, std::chrono::seconds max_time, message_priority priority) -> bool
 Enqueues a BLOB that is larger than max_data_size for sending. More...
 
auto broadcast_blob (message_id msg_id, memory::const_block blob, std::chrono::seconds max_time, message_priority priority) -> bool
 Enqueues a BLOB that is larger than max_data_size for broadcast. More...
 
auto broadcast_blob (message_id msg_id, memory::const_block blob, std::chrono::seconds max_time) -> bool
 Enqueues a BLOB that is larger than max_data_size for broadcast. More...
 
auto post_certificate (identifier_t target_id) -> bool
 Posts the certificate of this enpoint to the specified remote.
 
auto broadcast_certificate () -> bool
 Broadcasts the certificate of this enpoint to the whole bus.
 
auto say_not_a_router () -> bool
 Posts a message saying that this is not a router bus node. More...
 
auto say_still_alive () -> bool
 Posts a message saying that this endpoint is alive. More...
 
auto say_bye () -> bool
 Posts a message saying that this endpoint is about to disconnect. More...
 
void post_meta_message (message_id meta_msg_id, message_id msg_id)
 Post a message with another message type as its content. More...
 
void post_meta_message_to (identifier_t target_id, message_id meta_msg_id, message_id msg_id)
 Post a message with another message type as its content to target. More...
 
void say_subscribes_to (message_id)
 Broadcasts a message that this subscribes to message with given id. More...
 
void say_subscribes_to (identifier_t target_id, message_id)
 Posts a message that this subscribes to message with given id. More...
 
void say_unsubscribes_from (message_id)
 Broadcasts a message that this unsubscribes from message with given type. More...
 
void say_not_subscribed_to (identifier_t target_id, message_id)
 Posts a message that this is not subscribed to message with given type. More...
 
void query_subscriptions_of (identifier_t target_id)
 Posts a message requesting all subscriptions of a target node. More...
 
void query_subscribers_of (message_id)
 Posts a message requesting all subscribers of a given message type. More...
 
void clear_block_list ()
 Sends a message to router to clear its block filter for this endpoint. More...
 
void block_message_type (message_id)
 Sends a message to router to start blocking message type for this endpoint. More...
 
void clear_allow_list ()
 Sends a message to router to clear its allow filter for this endpoint. More...
 
void allow_message_type (message_id)
 Sends a message to router to start blocking message type for this endpoint. More...
 
void query_certificate_of (identifier_t endpoint_id)
 Sends a message requesting remote endpoint certificate.
 
auto respond_to (const message_info &info, message_id msg_id, message_view message) -> bool
 Posts a message as a response to another received message. More...
 
auto respond_to (const message_info &info, message_id msg_id) -> bool
 Posts a message as a response to another received message.
 
auto process_one (message_id msg_id, method_handler handler) -> bool
 Processes a single received message of specified type with a handler. More...
 
template<typename Class , bool(Class::*)(const message_context &, stored_message &) MemFnPtr>
auto process_one (message_id msg_id, member_function_constant< bool(Class::*)(const message_context &, stored_message &), MemFnPtr > method, Class *instance) -> bool
 Processes a single received message of specified type with a method. More...
 
auto process_all (message_id msg_id, method_handler handler) -> span_size_t
 Processes all received messages of specified type with a handler. More...
 
auto process_everything (method_handler handler) -> span_size_t
 Processes all received messages regardles of type with a handler.
 
- Public Member Functions inherited from eagine::interface< connection_user >
constexpr interface (const interface &)=delete
 Not copyable.
 
auto operator= (interface &&)=delete
 Not move assignable.
 
auto operator= (const interface &)=delete
 Not copy assignable.
 
- Public Member Functions inherited from eagine::main_ctx_object
 main_ctx_object (identifier obj_id, main_ctx_parent parent) noexcept
 Initialization from object id and parent.
 
auto process_instance_id () const noexcept -> process_instance_id_t
 Returns the process id.
 
auto main_context () const noexcept -> main_ctx &
 Returns a reference to the main context singleton.
 
auto app_config () const noexcept -> application_config &
 Returns a reference to the application config object.
 
auto as_parent () noexcept -> main_ctx_object_parent_info
 Returns this as main_ctx_object_parent_info.
 
template<typename T >
auto cfg_init (string_view key, T initial, string_view tag={}) -> T
 Reads and returns the configuration value identified by key.
 
template<typename Extractable , typename T >
auto cfg_extr (string_view key, T initial, string_view tag={}, type_identity< Extractable >={}) -> T
 Reads and returns the configuration value identified by key.
 
- Public Member Functions inherited from eagine::named_logging_object< main_ctx_log_backend_getter >
 named_logging_object (identifier id, main_ctx_log_backend_getter backend_getter) noexcept
 Constructor from identifier and backend_getter object. More...
 
 named_logging_object (identifier id, const named_logging_object &parent) noexcept
 Constructor from logger id and parent logging object.
 
 named_logging_object () noexcept=default
 Construct logging object without backend.
 
 named_logging_object (named_logging_object &&temp) noexcept
 Move constructor.
 
 named_logging_object (const named_logging_object &that) noexcept
 Copy constructor.
 
auto operator= (named_logging_object &&) noexcept -> named_logging_object &=default
 Move assignment operator.
 
auto operator= (const named_logging_object &) -> named_logging_object &=default
 Copy assignment operator.
 
constexpr auto object_id () const noexcept
 Returns the identifier of this logging object.
 
void object_description (string_view display_name, string_view description) noexcept
 Sets the human-readable name and description of this object.
 
auto log_fatal (string_view format) noexcept
 Create a log message entry for fatal error, with specified format. More...
 
auto log_error (string_view format) noexcept
 Create a log message entry for error, with specified format. More...
 
auto log_warning (string_view format) noexcept
 Create a log message entry for warning, with specified format. More...
 
auto log_info (string_view format) noexcept
 Create a log message entry for information, with specified format. More...
 
auto log_stat (string_view format) noexcept
 Create a log message entry for statistic, with specified format. More...
 
auto log_debug (string_view format) noexcept
 Create a log message entry for debugging, with specified format. More...
 
auto log_trace (string_view format) noexcept
 Create a log message entry for tracing, with specified format. More...
 
auto log_backtrace (string_view format) noexcept
 Create a log message entry for backtracing, with specified format. More...
 
auto log_debug_stream () noexcept
 Returns a log entry stream for debug messages. More...
 
auto log_error_stream () noexcept
 Returns a log entry stream for error messages. More...
 
auto log_chart_sample (identifier series, float value) noexcept -> named_logging_object &
 Stores a new value in the specified chart data series.
 
auto log_chart_sample (identifier series, const tagged_quantity< T, U > &qty) noexcept -> std::enable_if_t< std::is_convertible_v< T, float >, named_logging_object & >
 Stores a new value in the specified chart data series.
 
auto log_chart_sample (identifier series, const valid_if< T, P > &opt_value) noexcept -> named_logging_object &
 Stores a new value in the specified chart data series.
 
- Public Member Functions inherited from eagine::basic_logger< main_ctx_log_backend_getter >
auto backend () noexcept
 Returns a pointer to the backend of this logger object.
 
auto instance_id () const noexcept -> logger_instance_id
 Returns the unique id of this logger instance.
 

Static Public Member Functions

static constexpr auto is_valid_id (identifier_t id) noexcept -> bool
 Tests if the specified id is a valid endpoint id.
 

Additional Inherited Members

- Protected Member Functions inherited from eagine::interface< connection_user >
constexpr interface () noexcept=default
 Default constructible by derived.
 
constexpr interface (interface &&) noexcept=default
 Move constructible by derived.
 

Detailed Description

Message bus client endpoint that can send and receive messages.

See also
static_subscriber
subscriber

Member Typedef Documentation

◆ method_handler

using eagine::msgbus::endpoint::method_handler = callable_ref<bool(const message_context&, stored_message&)>

Alias for callable handling received messages.

See also
process_one
process_all

Member Function Documentation

◆ add_ca_certificate_pem()

void eagine::msgbus::endpoint::add_ca_certificate_pem ( memory::const_block  blk)

Adds CA certificate in a PEM-encoded memory block.

See also
add_certificate_pem

◆ add_certificate_pem()

void eagine::msgbus::endpoint::add_certificate_pem ( memory::const_block  blk)

Adds endpoint certificate in a PEM-encoded memory block.

See also
add_ca_certificate_pem

◆ allow_message_type()

void eagine::msgbus::endpoint::allow_message_type ( message_id  )

Sends a message to router to start blocking message type for this endpoint.

See also
clear_allow_list
block_message_type

◆ block_message_type()

void eagine::msgbus::endpoint::block_message_type ( message_id  )

Sends a message to router to start blocking message type for this endpoint.

See also
clear_block_list
allow_message_type

◆ broadcast_blob() [1/2]

auto eagine::msgbus::endpoint::broadcast_blob ( message_id  msg_id,
memory::const_block  blob,
std::chrono::seconds  max_time 
) -> bool
inline

Enqueues a BLOB that is larger than max_data_size for broadcast.

See also
post
post_signed
post_value
max_data_size

◆ broadcast_blob() [2/2]

auto eagine::msgbus::endpoint::broadcast_blob ( message_id  msg_id,
memory::const_block  blob,
std::chrono::seconds  max_time,
message_priority  priority 
) -> bool
inline

Enqueues a BLOB that is larger than max_data_size for broadcast.

See also
post
post_signed
post_value
max_data_size

◆ clear_allow_list()

void eagine::msgbus::endpoint::clear_allow_list ( )

Sends a message to router to clear its allow filter for this endpoint.

See also
allow_message_type
clear_block_list

◆ clear_block_list()

void eagine::msgbus::endpoint::clear_block_list ( )

Sends a message to router to clear its block filter for this endpoint.

See also
block_message_type
clear_allow_list

◆ ctx()

auto eagine::msgbus::endpoint::ctx ( ) -> context&
inlinenoexcept

Returns a reference to the message bus context.

See also
msgbus::context

◆ get_id()

auto eagine::msgbus::endpoint::get_id ( ) const
inlinenoexcept

Returns the unique id of this endpoint.

See also
set_id
has_id
is_valid_id

◆ get_preconfigured_id()

auto eagine::msgbus::endpoint::get_preconfigured_id ( ) const
inlinenoexcept

Returns the preconfigured id of this endpoint.

See also
preconfigure_id
has_preconfigured_id
is_valid_id

◆ has_id()

auto eagine::msgbus::endpoint::has_id ( ) const -> bool
inlinenoexcept

Indicates if this endpoint has valid id (set manually or from the bus).

See also
set_id
get_id
is_valid_id

◆ has_preconfigured_id()

auto eagine::msgbus::endpoint::has_preconfigured_id ( ) const -> bool
inlinenoexcept

Indicates if this endpoint has a preconfigured id (or should request one).

See also
preconfigure_id
get_preconfigured_id
is_valid_id

◆ post()

auto eagine::msgbus::endpoint::post ( message_id  msg_id,
message_view  message 
) -> bool
inline

Enqueues a message with the specified id/type for sending.

See also
post_signed
post_value
post_blob

Referenced by respond_to().

◆ post_blob()

auto eagine::msgbus::endpoint::post_blob ( message_id  msg_id,
identifier_t  target_id,
memory::const_block  blob,
std::chrono::seconds  max_time,
message_priority  priority 
) -> bool
inline

Enqueues a BLOB that is larger than max_data_size for sending.

See also
post
post_signed
post_value
max_data_size

◆ post_meta_message()

void eagine::msgbus::endpoint::post_meta_message ( message_id  meta_msg_id,
message_id  msg_id 
)

Post a message with another message type as its content.

See also
post
post_meta_message_to
default_serialize

◆ post_meta_message_to()

void eagine::msgbus::endpoint::post_meta_message_to ( identifier_t  target_id,
message_id  meta_msg_id,
message_id  msg_id 
)

Post a message with another message type as its content to target.

See also
post
post_meta_message
default_serialize

◆ post_signed()

auto eagine::msgbus::endpoint::post_signed ( message_id  ,
message_view  message 
) -> bool

Signs and enqueues a message with the specified id/type for sending.

See also
post
post_value

◆ post_value()

template<typename T >
auto eagine::msgbus::endpoint::post_value ( message_id  msg_id,
T &  value,
const message_info info = {} 
) -> bool
inline

Serializes the specified value and enqueues it for sending in message.

See also
post
post_signed
default_serialize

◆ preconfigure_id()

auto eagine::msgbus::endpoint::preconfigure_id ( identifier_t  id) -> auto&
inline

Preconfigures the unique id of this endpoint.

See also
set_id
has_preconfigured_id
get_preconfigured_id

◆ process_all()

auto eagine::msgbus::endpoint::process_all ( message_id  msg_id,
method_handler  handler 
) -> span_size_t

Processes all received messages of specified type with a handler.

See also
process_one
process_everything

◆ process_one() [1/2]

template<typename Class , bool(Class::*)(const message_context &, stored_message &) MemFnPtr>
auto eagine::msgbus::endpoint::process_one ( message_id  msg_id,
member_function_constant< bool(Class::*)(const message_context &, stored_message &), MemFnPtr >  method,
Class *  instance 
) -> bool
inline

Processes a single received message of specified type with a method.

See also
process_all
process_everything

◆ process_one() [2/2]

auto eagine::msgbus::endpoint::process_one ( message_id  msg_id,
method_handler  handler 
) -> bool

Processes a single received message of specified type with a handler.

See also
process_all
process_everything

Referenced by process_one().

◆ query_subscribers_of()

void eagine::msgbus::endpoint::query_subscribers_of ( message_id  )

Posts a message requesting all subscribers of a given message type.

See also
query_subscribers_of
say_subscribes_to

◆ query_subscriptions_of()

void eagine::msgbus::endpoint::query_subscriptions_of ( identifier_t  target_id)

Posts a message requesting all subscriptions of a target node.

See also
query_subscribers_of
say_subscribes_to

◆ respond_to()

auto eagine::msgbus::endpoint::respond_to ( const message_info info,
message_id  msg_id,
message_view  message 
) -> bool
inline

Posts a message as a response to another received message.

See also
message_info::setup_response

Referenced by respond_to().

◆ say_bye()

auto eagine::msgbus::endpoint::say_bye ( ) -> bool

Posts a message saying that this endpoint is about to disconnect.

See also
post
say_still_alive

Referenced by finish().

◆ say_not_a_router()

auto eagine::msgbus::endpoint::say_not_a_router ( ) -> bool

Posts a message saying that this is not a router bus node.

See also
post

◆ say_not_subscribed_to()

void eagine::msgbus::endpoint::say_not_subscribed_to ( identifier_t  target_id,
message_id   
)

Posts a message that this is not subscribed to message with given type.

See also
post_meta_message
say_subscribes_to
say_not_subscribed_to

◆ say_still_alive()

auto eagine::msgbus::endpoint::say_still_alive ( ) -> bool

Posts a message saying that this endpoint is alive.

See also
post
say_bye

◆ say_subscribes_to() [1/2]

void eagine::msgbus::endpoint::say_subscribes_to ( identifier_t  target_id,
message_id   
)

Posts a message that this subscribes to message with given id.

See also
post_meta_message_to
say_unsubscribes_from
say_not_subscribed_to

◆ say_subscribes_to() [2/2]

void eagine::msgbus::endpoint::say_subscribes_to ( message_id  )

Broadcasts a message that this subscribes to message with given id.

See also
post_meta_message
say_unsubscribes_from
say_not_subscribed_to

◆ say_unsubscribes_from()

void eagine::msgbus::endpoint::say_unsubscribes_from ( message_id  )

Broadcasts a message that this unsubscribes from message with given type.

See also
post_meta_message
say_subscribes_to
say_not_subscribed_to

◆ set_id()

auto eagine::msgbus::endpoint::set_id ( identifier  id) -> auto&
inline

Assigns the unique id of this endpoint.

See also
preconfigure_id
has_id
get_id
Note
Do not set manually, use preconfigure_id instead.

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

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).