C++ Actor Framework 1.0.0
|
Describes a protocol instance managing multiple connections. More...
#include <instance.hpp>
Classes | |
class | callee |
Provides a callback-based interface for certain BASP events. More... | |
Public Types | |
using | payload_writer = callback<bool(binary_serializer&)> |
Describes a function object responsible for writing the payload for a BASP message. | |
using | removed_published_actor = callback<void(const strong_actor_ptr&, uint16_t)> |
Describes a callback function object for remove_published_actor . | |
using | published_actor = std::pair<strong_actor_ptr, std::set<std::string>> |
Stores the address of a published actor along with its publicly visible messaging interface. | |
using | published_actor_map = std::unordered_map<uint16_t, published_actor> |
Maps ports to addresses and interfaces of published actors. | |
Public Member Functions | |
instance (abstract_broker *parent, callee &lstnr) | |
connection_state | handle (scheduler *ctx, new_data_msg &dm, header &hdr, bool is_payload) |
Handles received data and returns a config for receiving the next data or none if an error occurred. | |
void | handle_heartbeat (scheduler *ctx) |
Sends heartbeat messages to all valid nodes those are directly connected. | |
std::optional< routing_table::route > | lookup (const node_id &target) |
Returns a route to target or none on error. | |
void | flush (const routing_table::route &path) |
Flushes the underlying buffer of path . | |
void | write (scheduler *ctx, const routing_table::route &r, header &hdr, payload_writer *writer=nullptr) |
Sends a BASP message and implicitly flushes the output buffer of r . | |
void | add_published_actor (uint16_t port, strong_actor_ptr published_actor, std::set< std::string > published_interface) |
Adds a new actor to the map of published actors. | |
size_t | remove_published_actor (uint16_t port, removed_published_actor *cb=nullptr) |
Removes the actor currently assigned to port . | |
size_t | remove_published_actor (const actor_addr &whom, uint16_t port, removed_published_actor *cb=nullptr) |
Removes whom if it is still assigned to port or from all of its current ports if port == 0 . | |
bool | dispatch (scheduler *ctx, const strong_actor_ptr &sender, const node_id &dest_node, uint64_t dest_actor, uint8_t flags, message_id mid, const message &msg) |
Returns true if a path to destination existed, false otherwise. | |
proxy_registry & | proxies () |
Returns the actor namespace associated to this BASP protocol instance. | |
routing_table & | tbl () |
Returns the routing table of this BASP instance. | |
const published_actor_map & | published_actors () const |
Returns the current mapping of ports to addresses and interfaces of published actors. | |
void | write_server_handshake (scheduler *ctx, byte_buffer &out_buf, std::optional< uint16_t > port) |
Writes the server handshake containing the information of the actor published at port to buf . | |
void | write_client_handshake (scheduler *ctx, byte_buffer &buf) |
Writes the client handshake to buf . | |
void | write_monitor_message (scheduler *ctx, byte_buffer &buf, const node_id &dest_node, actor_id aid) |
Writes an announce_proxy to buf . | |
void | write_down_message (scheduler *ctx, byte_buffer &buf, const node_id &dest_node, actor_id aid, const error &rsn) |
Writes a kill_proxy to buf . | |
void | write_heartbeat (scheduler *ctx, byte_buffer &buf) |
Writes a heartbeat to buf . | |
const node_id & | this_node () const |
detail::worker_hub< worker > & | hub () |
message_queue & | queue () |
actor_system & | system () |
const actor_system_config & | config () |
connection_state | handle (scheduler *ctx, connection_handle hdl, header &hdr, byte_buffer *payload) |
Static Public Member Functions | |
static void | write (actor_system &sys, scheduler *ctx, byte_buffer &buf, header &hdr, payload_writer *pw=nullptr) |
Writes a header followed by its payload to storage . | |
Describes a protocol instance managing multiple connections.
void caf::io::basp::instance::write | ( | scheduler * | ctx, |
const routing_table::route & | r, | ||
header & | hdr, | ||
payload_writer * | writer = nullptr ) |
Sends a BASP message and implicitly flushes the output buffer of r
.
This function will update hdr.payload_len
if a payload was written.
void caf::io::basp::instance::write_server_handshake | ( | scheduler * | ctx, |
byte_buffer & | out_buf, | ||
std::optional< uint16_t > | port ) |
Writes the server handshake containing the information of the actor published at port
to buf
.
If port == none
or if no actor is published at this port then a standard handshake is written (e.g. used when establishing direct connections on-the-fly).