aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/service/monservice.h
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/monlib/service/monservice.h
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/monlib/service/monservice.h')
-rw-r--r--library/cpp/monlib/service/monservice.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/library/cpp/monlib/service/monservice.h b/library/cpp/monlib/service/monservice.h
new file mode 100644
index 00000000000..8f5e52fcdb2
--- /dev/null
+++ b/library/cpp/monlib/service/monservice.h
@@ -0,0 +1,73 @@
+#pragma once
+
+#include "service.h"
+#include "auth.h"
+#include "mon_service_http_request.h"
+
+#include <library/cpp/monlib/service/pages/index_mon_page.h>
+#include <library/cpp/monlib/service/pages/mon_page.h>
+
+#include <util/system/progname.h>
+
+#include <functional>
+
+namespace NMonitoring {
+ class TMonService2: public TMtHttpServer {
+ protected:
+ const TString Title;
+ char StartTime[26];
+ TIntrusivePtr<TIndexMonPage> IndexMonPage;
+ THolder<IAuthProvider> AuthProvider_;
+
+ public:
+ static THttpServerOptions HttpServerOptions(ui16 port, const TString& host, ui32 threads) {
+ THttpServerOptions opts(port);
+ if (!host.empty()) {
+ opts.SetHost(host);
+ }
+ opts.SetClientTimeout(TDuration::Minutes(1));
+ opts.EnableCompression(true);
+ opts.SetThreads(threads);
+ opts.SetMaxConnections(std::max<ui32>(100, threads));
+ opts.EnableRejectExcessConnections(true);
+ return opts;
+ }
+
+ static THttpServerOptions HttpServerOptions(ui16 port, ui32 threads) {
+ return HttpServerOptions(port, TString(), threads);
+ }
+
+ public:
+ explicit TMonService2(ui16 port, const TString& title = GetProgramName(), THolder<IAuthProvider> auth = nullptr);
+ explicit TMonService2(ui16 port, ui32 threads, const TString& title = GetProgramName(), THolder<IAuthProvider> auth = nullptr);
+ explicit TMonService2(ui16 port, const TString& host, ui32 threads, const TString& title = GetProgramName(), THolder<IAuthProvider> auth = nullptr);
+ explicit TMonService2(const THttpServerOptions& options, const TString& title = GetProgramName(), THolder<IAuthProvider> auth = nullptr);
+ explicit TMonService2(const THttpServerOptions& options, TSimpleSharedPtr<IThreadPool> pool, const TString& title = GetProgramName(), THolder<IAuthProvider> auth = nullptr);
+
+ ~TMonService2() override {
+ }
+
+ const char* GetStartTime() const {
+ return StartTime;
+ }
+
+ const TString& GetTitle() const {
+ return Title;
+ }
+
+ virtual void ServeRequest(IOutputStream& out, const NMonitoring::IHttpRequest& request);
+ virtual void OutputIndex(IOutputStream& out);
+ virtual void OutputIndexPage(IOutputStream& out);
+ virtual void OutputIndexBody(IOutputStream& out);
+
+ void Register(IMonPage* page);
+ void Register(TMonPagePtr page);
+
+ TIndexMonPage* RegisterIndexPage(const TString& path, const TString& title);
+
+ IMonPage* FindPage(const TString& relativePath);
+ TIndexMonPage* FindIndexPage(const TString& relativePath);
+ void SortPages();
+ };
+
+}