23#include <flow/log/log.hpp>
24#include <boost/make_shared.hpp>
25#include <boost/move/unique_ptr.hpp>
26#include <boost/shared_ptr.hpp>
70template<
typename Server_session_t>
72 public flow::log::Log_context,
73 private boost::noncopyable
80 static_assert(Session_obj::S_SHM_ENABLED,
81 "Server_context facilitates the use of Flow-IPC zero-copy (SHM) facilities for "
82 "zero-copy performance in using capnp-RPC; therefore the supplied Server_session_t template "
83 "parameter must be a SHM-enabled Server_session variant, session::shm::*::Server_session*.");
104 using Ptr = boost::movelib::unique_ptr<Server_context>;
158 using Session_ptr =
typename Vat_network::Shm_lender_borrower_ptr;
182 explicit Server_context(flow::log::Logger* logger_ptr, kj::AsyncIoContext* kj_io,
184 bool enable_hndl_transport,
bool sans_shm_transport);
218template<
typename Server_session_t>
221 bool enable_hndl_transport,
222 bool sans_shm_transport) :
227 m_session(boost::make_shared<
Session_obj>(std::move(session))),
228 m_network(get_logger(), kj_io,
230 std::move(bidir_transport),
234 FLOW_LOG_INFO(
"rpc::Server_ctx [" << *
this <<
"]: Created in PEER state (presumably by Context_server); "
235 "zero-copy-enabled? = [" << (!sans_shm_transport) <<
"].");
238 { on_session_hosed(logger_ptr, *session, err_code); });
241template<
typename Server_session_t>
244 FLOW_LOG_INFO(
"rpc::Server_ctx [" << *
this <<
"]: "
245 "Shutting down. Session_vat_network shall shut down; then the ipc::session::Session. "
246 "However: straggling capnp-RPC message(s) may keep the latter alive a bit longer than immediately "
247 "following Session_vat_network's destruction.");
250template<
typename Server_session_t>
254 FLOW_LOG_SET_CONTEXT(logger_ptr, Log_component::S_RPC);
255 FLOW_LOG_INFO(
"rpc::Server_ctx-created ipc::session::Session [" << session <<
"]: session-hosed handler fired "
256 "(code [" << err_code <<
"] [" << err_code.message() <<
"]). This is likely normal, as the "
257 "opposing process decided to end session; the RPC-system will have detected same, and user "
258 "RPC session should be ended or ending imminently, at which point proper user code shall "
259 "shut-down this Server_ctx which will shut down the Session_vat_network and lastly the "
260 "ipc::session::Session.");
265template<
typename Server_session_t>
272template<
typename Server_session_t>
279template<
typename Server_session_t>
283 return m_session.get();
286template<
typename Server_session_t>
293template<
typename Server_session_t>
296 return os <<
"[session[" << *(val.
session()) <<
"] vat_netwk[" << *(val.
vat_network()) <<
"]]@" << &val;
The mirror of an opposing PEER-state Client_context, as generated via successful Context_server::acce...
Session_ptr m_session
Session in PEER state.
~Server_context()
Identical semantics to Client_context. See that doc header.
Vat_network * vat_network()
Returns pointer to Session_vat_network established for use in your Rpc_system.
boost::movelib::unique_ptr< Server_context > Ptr
Movable smart-pointer handle to a *this.
Session_obj * session()
Returns pointer to Session_obj (in PEER state).
Server_context(flow::log::Logger *logger_ptr, kj::AsyncIoContext *kj_io, Session_obj &&session, Native_handle &&bidir_transport, bool enable_hndl_transport, bool sans_shm_transport)
Constructs us in PEER state.
Server_session_t Session_obj
Convenience alias for template arg.
static void on_session_hosed(flow::log::Logger *logger_ptr, const Session_obj &session, const Error_code &err_code)
Spiritually identical to Client_context::on_session_hosed(), including in being static and capturing ...
typename Session_obj::Vat_network Vat_network
The Session_vat_network concrete type – and capnp::VatNetwork interface impl – that we produce.
Vat_network m_network
The established Vat_network.
typename Vat_network::Shm_lender_borrower_ptr Session_ptr
Basically shared_ptr<Session_obj>.
Provides Flow-IPC's integration with Cap'n Proto's Remote Procedure Call (RPC) layer,...
std::ostream & operator<<(std::ostream &os, const Client_context< Client_session_t > &val)
Prints string representation of the given Client_context to the given ostream.
Log_component
The flow::log::Component payload enumeration containing various log components used by Flow-IPC inter...
flow::Error_code Error_code
Short-hand for flow::Error_code which is very common.
This is the friend facade of Server_context that exposes the internal-use private API,...
Non-template base for Session_vat_network (constants, types, and what-not).
A monolayer-thin wrapper around a native handle, a/k/a descriptor a/k/a FD.