aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/service/service.h
diff options
context:
space:
mode:
authorelviandante <elviandante@yandex-team.ru>2022-02-10 16:49:47 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:47 +0300
commit621a17b75565a8d70df465a0ac5c93a7c6d2e61f (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/monlib/service/service.h
parent643ddee8bd6125a18c4b1506c35bee857f64f4d2 (diff)
downloadydb-621a17b75565a8d70df465a0ac5c93a7c6d2e61f.tar.gz
Restoring authorship annotation for <elviandante@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib/service/service.h')
-rw-r--r--library/cpp/monlib/service/service.h110
1 files changed, 55 insertions, 55 deletions
diff --git a/library/cpp/monlib/service/service.h b/library/cpp/monlib/service/service.h
index 2ea5f0f4a2..2f66dddaf8 100644
--- a/library/cpp/monlib/service/service.h
+++ b/library/cpp/monlib/service/service.h
@@ -1,65 +1,65 @@
#pragma once
-
+
#include <library/cpp/coroutine/engine/impl.h>
#include <library/cpp/coroutine/listener/listen.h>
#include <library/cpp/http/fetch/httpheader.h>
#include <library/cpp/http/server/http.h>
#include <library/cpp/logger/all.h>
-#include <util/network/ip.h>
+#include <util/network/ip.h>
#include <library/cpp/cgiparam/cgiparam.h>
-
+
#include <functional>
-
+
struct TMonitor;
-
-namespace NMonitoring {
- struct IHttpRequest {
+
+namespace NMonitoring {
+ struct IHttpRequest {
virtual ~IHttpRequest() {
}
- virtual const char* GetURI() const = 0;
- virtual const char* GetPath() const = 0;
+ virtual const char* GetURI() const = 0;
+ virtual const char* GetPath() const = 0;
virtual const TCgiParameters& GetParams() const = 0;
virtual const TCgiParameters& GetPostParams() const = 0;
virtual TStringBuf GetPostContent() const = 0;
virtual HTTP_METHOD GetMethod() const = 0;
virtual const THttpHeaders& GetHeaders() const = 0;
virtual TString GetRemoteAddr() const = 0;
- };
- // first param - output stream to write result to
- // second param - URL of request
+ };
+ // first param - output stream to write result to
+ // second param - URL of request
typedef std::function<void(IOutputStream&, const IHttpRequest&)> THandler;
-
+
class TCoHttpServer: private TContListener::ICallBack {
- public:
- // initialize and schedule coroutines for execution
+ public:
+ // initialize and schedule coroutines for execution
TCoHttpServer(TContExecutor& executor, const TString& bindAddr, TIpPort port, THandler handler);
- void Start();
- void Stop();
-
- // this function implements THandler interface
- // by forwarding it to the httpserver
- // @note this call may be blocking; don't use inside coroutines
- // @throws may throw in case of connection error, etc
+ void Start();
+ void Stop();
+
+ // this function implements THandler interface
+ // by forwarding it to the httpserver
+ // @note this call may be blocking; don't use inside coroutines
+ // @throws may throw in case of connection error, etc
void ProcessRequest(IOutputStream&, const IHttpRequest&);
- private:
- class TConnection;
-
- // ICallBack implementation
+ private:
+ class TConnection;
+
+ // ICallBack implementation
void OnAcceptFull(const TAcceptFull& a) override;
void OnError() override;
- private:
- TContExecutor& Executor;
- TContListener Listener;
- THandler Handler;
+ private:
+ TContExecutor& Executor;
+ TContListener Listener;
+ THandler Handler;
TString BindAddr;
- TIpPort Port;
- };
-
+ TIpPort Port;
+ };
+
class TMtHttpServer: public THttpServer, private THttpServer::ICallBack {
- public:
+ public:
TMtHttpServer(const TOptions& options, THandler handler, IThreadFactory* pool = nullptr);
TMtHttpServer(const TOptions& options, THandler handler, TSimpleSharedPtr<IThreadPool> pool);
@@ -82,31 +82,31 @@ namespace NMonitoring {
*/
void Stop();
- private:
- class TConnection;
+ private:
+ class TConnection;
TClientRequest* CreateClient() override;
-
- THandler Handler;
- };
-
- // this class implements hybrid coroutine and threaded approach
- // requests for main page which holds counters and simple tables are served in a thread
- // requests for other pages which include access with inter-thread synchonization
- // will be served in a coroutine context
- class TMonService {
- public:
+
+ THandler Handler;
+ };
+
+ // this class implements hybrid coroutine and threaded approach
+ // requests for main page which holds counters and simple tables are served in a thread
+ // requests for other pages which include access with inter-thread synchonization
+ // will be served in a coroutine context
+ class TMonService {
+ public:
TMonService(TContExecutor& executor, TIpPort internalPort, TIpPort externalPort,
THandler coHandler, THandler mtHandler);
- void Start();
- void Stop();
+ void Start();
+ void Stop();
- protected:
+ protected:
void DispatchRequest(IOutputStream& out, const IHttpRequest&);
- private:
- TCoHttpServer CoServer;
- TMtHttpServer MtServer;
- THandler MtHandler;
- };
-
+ private:
+ TCoHttpServer CoServer;
+ TMtHttpServer MtServer;
+ THandler MtHandler;
+ };
+
}