59 ServerImpl(std::vector<std::shared_ptr<transport::IAcceptor>> acceptors,
60 std::unique_ptr<methods::IMethodProcessor> processor,
61 std::shared_ptr<executors::IAsyncExecutor>
executor,
62 std::shared_ptr<logging::Logger> logger)
73 }
catch (
const std::exception& e) {
75 "An exception was thrown when destructing a server but "
93 "This server has already been started.");
98 [weak_signal_handler =
100 const std::exception_ptr& ) {
101 const auto signal_handler = weak_signal_handler.lock();
102 if (signal_handler) {
103 signal_handler->stop();
129 const auto last_exception =
executor_->last_exception();
133 if (last_exception) {
134 std::rethrow_exception(last_exception);
140 std::vector<addresses::URI> uris;
143 uris.push_back(acceptor->local_address().to_uri());
149 [[nodiscard]] std::shared_ptr<executors::IExecutor>
executor()
override {
162 const std::shared_ptr<transport::IConnection>& connection) {
163 const auto handler = std::make_shared<ServerConnection>(
164 connection,
executor, processor, logger);
168 acceptor->local_address().to_string());
182 std::vector<std::shared_ptr<transport::IAcceptor>>
acceptors_;
Class of exceptions in cpp-msgpack-rpc library.
Class to handle Linux signals SIGINT and SIGTERM to stop a server.
Class of internal implementation of servers.
std::shared_ptr< logging::Logger > logger_
Logger.
std::vector< addresses::URI > local_endpoint_uris() override
Get the URIs of the local endpoints in this server.
void stop_acceptors()
Stop processing of acceptors.
void start_acceptors()
Start processing of acceptors.
~ServerImpl() override
Destructor.
std::shared_ptr< methods::IMethodProcessor > processor_
Processor of methods.
std::shared_ptr< executors::IAsyncExecutor > executor_
Executor.
std::atomic< bool > is_stopped_
Whether this server has been stopped.
void run_until_signal() override
Run processing of this server until SIGINT or SIGTERM is received.
std::shared_ptr< StopSignalHandler > stop_signal_handler_
Handler of signals to stop processing.
void stop() override
Stop processing of this server.
ServerImpl(std::vector< std::shared_ptr< transport::IAcceptor > > acceptors, std::unique_ptr< methods::IMethodProcessor > processor, std::shared_ptr< executors::IAsyncExecutor > executor, std::shared_ptr< logging::Logger > logger)
Constructor.
std::shared_ptr< executors::IExecutor > executor() override
Get the executor.
void start()
Start processing of this server.
std::vector< std::shared_ptr< transport::IAcceptor > > acceptors_
Acceptors.
std::atomic< bool > is_started_
Whether this server has been started.
Definition of IAcceptor class.
Definition of IAsyncExecutor class.
Definition of IConnection class.
Definition of IExecutor class.
Definition of IMethodProcessor class.
Definition of IServerImpl class.
Definition of Logger class.
#define MSGPACK_RPC_CRITICAL(LOGGER_PTR,...)
Write a critical log.
#define MSGPACK_RPC_DEBUG(LOGGER_PTR,...)
Write a debug log.
Definition of MsgpackRPCException class.
Namespace of internal implementation.
Definition of Server class.
Definition of StatusCode enumeration.
Definition of StopSignalHandler class.