From 8b0e68f48e5ede435709751bc4975bc8797471c9 Mon Sep 17 00:00:00 2001 From: cyan317 <120398799+cindyyan317@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:06:27 +0100 Subject: [PATCH] chore: Add counter for total messages waiting to be sent (#1691) --- src/util/requests/impl/WsConnectionImpl.hpp | 2 +- src/web/Server.hpp | 12 ++-- src/web/impl/WsBase.hpp | 20 +++++- tests/unit/web/ServerTests.cpp | 67 +++++++++++++++++---- 4 files changed, 78 insertions(+), 23 deletions(-) diff --git a/src/util/requests/impl/WsConnectionImpl.hpp b/src/util/requests/impl/WsConnectionImpl.hpp index 04eb95e01..99ce0a3e0 100644 --- a/src/util/requests/impl/WsConnectionImpl.hpp +++ b/src/util/requests/impl/WsConnectionImpl.hpp @@ -134,7 +134,7 @@ class WsConnectionImpl : public WsConnection { // The timer below can be called with no error code even if the operation is completed before the timeout, so we // need an additional flag here timer.async_wait([&cancellationSignal, isCompleted](boost::system::error_code errorCode) { - if (!errorCode and not *isCompleted) + if (!errorCode and not*isCompleted) cancellationSignal.emit(boost::asio::cancellation_type::terminal); }); operation(cyield); diff --git a/src/web/Server.hpp b/src/web/Server.hpp index 373c57c5f..e1d5b5f2c 100644 --- a/src/web/Server.hpp +++ b/src/web/Server.hpp @@ -69,10 +69,8 @@ namespace web { * @tparam HandlerType The executor to handle the requests */ template < - template - class PlainSessionType, - template - class SslSessionType, + template class PlainSessionType, + template class SslSessionType, SomeServerHandler HandlerType> class Detector : public std::enable_shared_from_this> { using std::enable_shared_from_this>::shared_from_this; @@ -191,10 +189,8 @@ class Detector : public std::enable_shared_from_this - class PlainSessionType, - template - class SslSessionType, + template class PlainSessionType, + template class SslSessionType, SomeServerHandler HandlerType> class Server : public std::enable_shared_from_this> { using std::enable_shared_from_this>::shared_from_this; diff --git a/src/web/impl/WsBase.hpp b/src/web/impl/WsBase.hpp index 889ed769e..d75335b6e 100644 --- a/src/web/impl/WsBase.hpp +++ b/src/web/impl/WsBase.hpp @@ -23,6 +23,9 @@ #include "rpc/common/Types.hpp" #include "util/Taggable.hpp" #include "util/log/Logger.hpp" +#include "util/prometheus/Gauge.hpp" +#include "util/prometheus/Label.hpp" +#include "util/prometheus/Prometheus.hpp" #include "web/DOSGuard.hpp" #include "web/interface/Concepts.hpp" #include "web/interface/ConnectionBase.hpp" @@ -71,6 +74,8 @@ template