3#include <xrpl/basics/contract.h>
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/server/Port.h>
6#include <xrpl/server/detail/Door.h>
7#include <xrpl/server/detail/io_list.h>
9#include <boost/asio.hpp>
10#include <boost/asio/executor_work_guard.hpp>
11#include <boost/asio/io_context.hpp>
72template <
class Handler>
83 boost::asio::strand<boost::asio::io_context::executor_type>
strand_;
117 boost::asio::io_context&
131template <
class Handler>
134 boost::asio::io_context& ioContext,
144template <
class Handler>
148 work_ = std::nullopt;
153template <
class Handler>
162 for (
auto const& port :
ports)
165 auto& internalPort =
ports_.back();
170 auto ep = sp->getEndpoint();
171 if (internalPort.port == 0u)
172 internalPort.port = ep.port();
173 eps.
emplace(port.name, std::move(ep));
181template <
class Handler>
186 work_ = std::nullopt;
191template <
class Handler>
195 return ios_.closed();
A generic endpoint for log messages.
Manages a set of objects performing asynchronous I/O.
std::vector< Port > ports_
ServerImpl(Handler &handler, boost::asio::io_context &ioContext, beast::Journal journal)
boost::asio::io_context & getIoContext()
Endpoints ports(std::vector< Port > const &ports) override
Set the listening port settings.
void close() override
Close the server.
std::optional< boost::asio::executor_work_guard< boost::asio::io_context::executor_type > > work_
boost::asio::strand< boost::asio::io_context::executor_type > strand_
std::chrono::system_clock clock_type
boost::asio::io_context & ioContext_
static constexpr auto kHistorySize
std::array< std::size_t, 64 > hist_
std::vector< std::weak_ptr< Door< Handler > > > list_
static int ceilLog2(unsigned long long x)
beast::Journal journal() override
Returns the Journal associated with the server.
virtual void close()=0
Close the server.
virtual ~Server()=default
Destroy the server.
virtual beast::Journal journal()=0
Returns the Journal associated with the server.
virtual Endpoints ports(std::vector< Port > const &v)=0
Set the listening port settings.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::unordered_map< std::string, boost::asio::ip::tcp::endpoint > Endpoints
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)