mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add peer count to HTTP server properties
This commit is contained in:
@@ -23,6 +23,14 @@
|
||||
namespace ripple {
|
||||
namespace HTTP {
|
||||
|
||||
std::atomic <std::size_t> Peer::s_count_;
|
||||
|
||||
std::size_t
|
||||
Peer::count()
|
||||
{
|
||||
return s_count_.load();
|
||||
}
|
||||
|
||||
Peer::Peer (ServerImpl& server, Port const& port, beast::Journal journal)
|
||||
: journal_ (journal)
|
||||
, server_ (server)
|
||||
@@ -37,6 +45,8 @@ Peer::Peer (ServerImpl& server, Port const& port, beast::Journal journal)
|
||||
, bytes_in_ (0)
|
||||
, bytes_out_ (0)
|
||||
{
|
||||
++s_count_;
|
||||
|
||||
static std::atomic <int> sid;
|
||||
id_ = std::string("#") + std::to_string(sid++);
|
||||
|
||||
@@ -92,6 +102,8 @@ Peer::~Peer ()
|
||||
|
||||
if (journal_.trace) journal_.trace <<
|
||||
id_ << " destroyed";
|
||||
|
||||
--s_count_;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <beast/module/asio/http/HTTPRequestParser.h>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
@@ -97,7 +98,13 @@ private:
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
static std::atomic <std::size_t> s_count_;
|
||||
|
||||
public:
|
||||
static
|
||||
std::size_t
|
||||
count();
|
||||
|
||||
Peer (ServerImpl& impl, Port const& port, beast::Journal journal);
|
||||
~Peer ();
|
||||
|
||||
|
||||
@@ -153,6 +153,8 @@ ServerImpl::onWrite (beast::PropertyStream::Map& map)
|
||||
|
||||
// VFALCO TODO Write the list of doors
|
||||
|
||||
map ["peers"] = Peer::count();
|
||||
|
||||
{
|
||||
beast::PropertyStream::Set set ("sessions", map);
|
||||
for (auto const& stat : stats_)
|
||||
|
||||
Reference in New Issue
Block a user