diff options
author | Sergey Polovko <sergey@polovko.me> | 2022-02-10 16:47:02 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:02 +0300 |
commit | 3e0b762a82514bac89c1dd6ea7211e381d8aa248 (patch) | |
tree | c2d1b379ecaf05ca8f11ed0b5da9d1a950e6e554 /library/cpp/monlib/service/pages | |
parent | ab3783171cc30e262243a0227c86118f7080c896 (diff) | |
download | ydb-3e0b762a82514bac89c1dd6ea7211e381d8aa248.tar.gz |
Restoring authorship annotation for Sergey Polovko <sergey@polovko.me>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/service/pages')
19 files changed, 305 insertions, 305 deletions
diff --git a/library/cpp/monlib/service/pages/diag_mon_page.h b/library/cpp/monlib/service/pages/diag_mon_page.h index 761194d4ec..2d90d5850d 100644 --- a/library/cpp/monlib/service/pages/diag_mon_page.h +++ b/library/cpp/monlib/service/pages/diag_mon_page.h @@ -3,14 +3,14 @@ #include "pre_mon_page.h" namespace NMonitoring { - // internal diagnostics page - struct TDiagMonPage: public TPreMonPage { - TDiagMonPage() - : TPreMonPage("diag", "Diagnostics Page") - { - } + // internal diagnostics page + struct TDiagMonPage: public TPreMonPage { + TDiagMonPage() + : TPreMonPage("diag", "Diagnostics Page") + { + } void OutputText(IOutputStream& out, NMonitoring::IMonHttpRequest&) override; - }; + }; -} +} diff --git a/library/cpp/monlib/service/pages/html_mon_page.cpp b/library/cpp/monlib/service/pages/html_mon_page.cpp index eb4eb3b66c..8c178e135f 100644 --- a/library/cpp/monlib/service/pages/html_mon_page.cpp +++ b/library/cpp/monlib/service/pages/html_mon_page.cpp @@ -1,6 +1,6 @@ #include "html_mon_page.h" -#include <library/cpp/monlib/service/pages/templates.h> +#include <library/cpp/monlib/service/pages/templates.h> using namespace NMonitoring; @@ -20,8 +20,8 @@ void THtmlMonPage::Output(NMonitoring::IMonHttpRequest& request) { out << "<script language='javascript' type='text/javascript' src='https://yastatic.net/bootstrap/3.3.1/js/bootstrap.min.js'></script>\n"; if (OutputTableSorterJsCss) { - out << "<link rel='stylesheet' href='/jquery.tablesorter.css'>\n"; - out << "<script language='javascript' type='text/javascript' src='/jquery.tablesorter.js'></script>\n"; + out << "<link rel='stylesheet' href='/jquery.tablesorter.css'>\n"; + out << "<script language='javascript' type='text/javascript' src='/jquery.tablesorter.js'></script>\n"; } out << "<style type=\"text/css\">\n"; @@ -34,7 +34,7 @@ void THtmlMonPage::Output(NMonitoring::IMonHttpRequest& request) { out << "</style>\n"; } BODY() { - OutputNavBar(out); + OutputNavBar(out); DIV_CLASS("container") { if (!!Title) { diff --git a/library/cpp/monlib/service/pages/html_mon_page.h b/library/cpp/monlib/service/pages/html_mon_page.h index e87c53b62b..305af355cb 100644 --- a/library/cpp/monlib/service/pages/html_mon_page.h +++ b/library/cpp/monlib/service/pages/html_mon_page.h @@ -3,14 +3,14 @@ #include "mon_page.h" namespace NMonitoring { - struct THtmlMonPage: public IMonPage { - THtmlMonPage(const TString& path, - const TString& title = TString(), - bool outputTableSorterJsCss = false) + struct THtmlMonPage: public IMonPage { + THtmlMonPage(const TString& path, + const TString& title = TString(), + bool outputTableSorterJsCss = false) : IMonPage(path, title) - , OutputTableSorterJsCss(outputTableSorterJsCss) - { - } + , OutputTableSorterJsCss(outputTableSorterJsCss) + { + } void Output(NMonitoring::IMonHttpRequest& request) override; @@ -19,7 +19,7 @@ namespace NMonitoring { virtual void OutputContent(NMonitoring::IMonHttpRequest& request) = 0; - bool OutputTableSorterJsCss; - }; + bool OutputTableSorterJsCss; + }; -} +} diff --git a/library/cpp/monlib/service/pages/index_mon_page.cpp b/library/cpp/monlib/service/pages/index_mon_page.cpp index 83ff8b529a..65f6c1ea59 100644 --- a/library/cpp/monlib/service/pages/index_mon_page.cpp +++ b/library/cpp/monlib/service/pages/index_mon_page.cpp @@ -1,7 +1,7 @@ -#include "index_mon_page.h" - +#include "index_mon_page.h" + #include <util/generic/cast.h> -#include <util/string/ascii.h> +#include <util/string/ascii.h> using namespace NMonitoring; @@ -51,7 +51,7 @@ void TIndexMonPage::Output(IMonHttpRequest& request) { } } -void TIndexMonPage::OutputIndex(IOutputStream& out, bool pathEndsWithSlash) { +void TIndexMonPage::OutputIndex(IOutputStream& out, bool pathEndsWithSlash) { TGuard<TMutex> g(Mtx); for (auto& Page : Pages) { IMonPage* page = Page.Get(); @@ -65,7 +65,7 @@ void TIndexMonPage::OutputIndex(IOutputStream& out, bool pathEndsWithSlash) { } } -void TIndexMonPage::Register(TMonPagePtr page) { +void TIndexMonPage::Register(TMonPagePtr page) { TGuard<TMutex> g(Mtx); auto insres = PagesByPath.insert(std::make_pair("/" + page->GetPath(), page)); if (insres.second) { @@ -80,10 +80,10 @@ void TIndexMonPage::Register(TMonPagePtr page) { // this already present, replace it insres.first->second = page; } - page->Parent = this; + page->Parent = this; } -TIndexMonPage* TIndexMonPage::RegisterIndexPage(const TString& path, const TString& title) { +TIndexMonPage* TIndexMonPage::RegisterIndexPage(const TString& path, const TString& title) { TGuard<TMutex> g(Mtx); TIndexMonPage* page = VerifyDynamicCast<TIndexMonPage*>(FindPage(path)); if (page) { @@ -116,7 +116,7 @@ void TIndexMonPage::OutputCommonJsCss(IOutputStream& out) { out << "<script language='javascript' type='text/javascript' src='https://yastatic.net/bootstrap/3.3.1/js/bootstrap.min.js'></script>\n"; } -void TIndexMonPage::OutputHead(IOutputStream& out) { +void TIndexMonPage::OutputHead(IOutputStream& out) { out << "<head>\n"; OutputCommonJsCss(out); out << "<title>" << Title << "</title>\n"; @@ -128,19 +128,19 @@ void TIndexMonPage::OutputBody(IMonHttpRequest& req) { out << "<body>\n"; // part of common navbar - OutputNavBar(out); + OutputNavBar(out); out << "<div class='container'>\n" - << "<h2>" << Title << "</h2>\n"; + << "<h2>" << Title << "</h2>\n"; OutputIndex(out, req.GetPathInfo().EndsWith('/')); out << "<div>\n" << "</body>\n"; } -void TIndexMonPage::SortPages() { +void TIndexMonPage::SortPages() { TGuard<TMutex> g(Mtx); std::sort(Pages.begin(), Pages.end(), [](const TMonPagePtr& a, const TMonPagePtr& b) { - return AsciiCompareIgnoreCase(a->GetTitle(), b->GetTitle()) < 0; + return AsciiCompareIgnoreCase(a->GetTitle(), b->GetTitle()) < 0; }); } diff --git a/library/cpp/monlib/service/pages/index_mon_page.h b/library/cpp/monlib/service/pages/index_mon_page.h index bf514a3105..6831fd15ca 100644 --- a/library/cpp/monlib/service/pages/index_mon_page.h +++ b/library/cpp/monlib/service/pages/index_mon_page.h @@ -3,36 +3,36 @@ #include "mon_page.h" namespace NMonitoring { - struct TIndexMonPage: public IMonPage { - TMutex Mtx; - typedef TVector<TMonPagePtr> TPages; - TPages Pages; - typedef THashMap<TString, TMonPagePtr> TPagesByPath; - TPagesByPath PagesByPath; + struct TIndexMonPage: public IMonPage { + TMutex Mtx; + typedef TVector<TMonPagePtr> TPages; + TPages Pages; + typedef THashMap<TString, TMonPagePtr> TPagesByPath; + TPagesByPath PagesByPath; - TIndexMonPage(const TString& path, const TString& title) - : IMonPage(path, title) - { - } + TIndexMonPage(const TString& path, const TString& title) + : IMonPage(path, title) + { + } - ~TIndexMonPage() override { - } + ~TIndexMonPage() override { + } void Output(IMonHttpRequest& request) override; void OutputIndexPage(IMonHttpRequest& request); - virtual void OutputIndex(IOutputStream& out, bool pathEndsWithSlash); - virtual void OutputCommonJsCss(IOutputStream& out); - void OutputHead(IOutputStream& out); + virtual void OutputIndex(IOutputStream& out, bool pathEndsWithSlash); + virtual void OutputCommonJsCss(IOutputStream& out); + void OutputHead(IOutputStream& out); void OutputBody(IMonHttpRequest& out); - void Register(TMonPagePtr page); - TIndexMonPage* RegisterIndexPage(const TString& path, const TString& title); + void Register(TMonPagePtr page); + TIndexMonPage* RegisterIndexPage(const TString& path, const TString& title); - IMonPage* FindPage(const TString& relativePath); - TIndexMonPage* FindIndexPage(const TString& relativePath); + IMonPage* FindPage(const TString& relativePath); + TIndexMonPage* FindIndexPage(const TString& relativePath); - void SortPages(); + void SortPages(); void ClearPages(); - }; + }; -} +} diff --git a/library/cpp/monlib/service/pages/mon_page.cpp b/library/cpp/monlib/service/pages/mon_page.cpp index 72033b1699..1bffd42027 100644 --- a/library/cpp/monlib/service/pages/mon_page.cpp +++ b/library/cpp/monlib/service/pages/mon_page.cpp @@ -9,28 +9,28 @@ IMonPage::IMonPage(const TString& path, const TString& title) Y_VERIFY(!Path.StartsWith('/')); Y_VERIFY(!Path.EndsWith('/')); } - -void IMonPage::OutputNavBar(IOutputStream& out) { - TVector<const IMonPage*> parents; - for (const IMonPage* p = this; p; p = p->Parent) { - parents.push_back(p); - } - std::reverse(parents.begin(), parents.end()); - - out << "<ol class='breadcrumb'>\n"; - - TString absolutePath; - for (size_t i = 0; i < parents.size(); ++i) { - const TString& title = parents[i]->GetTitle(); - if (i == parents.size() - 1) { - out << "<li>" << title << "</li>\n"; - } else { - if (!absolutePath.EndsWith('/')) { - absolutePath += '/'; - } - absolutePath += parents[i]->GetPath(); - out << "<li class='active'><a href='" << absolutePath << "'>" << title << "</a></li>\n"; - } - } - out << "</ol>\n"; -} + +void IMonPage::OutputNavBar(IOutputStream& out) { + TVector<const IMonPage*> parents; + for (const IMonPage* p = this; p; p = p->Parent) { + parents.push_back(p); + } + std::reverse(parents.begin(), parents.end()); + + out << "<ol class='breadcrumb'>\n"; + + TString absolutePath; + for (size_t i = 0; i < parents.size(); ++i) { + const TString& title = parents[i]->GetTitle(); + if (i == parents.size() - 1) { + out << "<li>" << title << "</li>\n"; + } else { + if (!absolutePath.EndsWith('/')) { + absolutePath += '/'; + } + absolutePath += parents[i]->GetPath(); + out << "<li class='active'><a href='" << absolutePath << "'>" << title << "</a></li>\n"; + } + } + out << "</ol>\n"; +} diff --git a/library/cpp/monlib/service/pages/mon_page.h b/library/cpp/monlib/service/pages/mon_page.h index e396612bb0..da151e5255 100644 --- a/library/cpp/monlib/service/pages/mon_page.h +++ b/library/cpp/monlib/service/pages/mon_page.h @@ -1,66 +1,66 @@ #pragma once -#include <library/cpp/monlib/service/service.h> -#include <library/cpp/monlib/service/mon_service_http_request.h> - +#include <library/cpp/monlib/service/service.h> +#include <library/cpp/monlib/service/mon_service_http_request.h> + #include <util/generic/string.h> #include <util/generic/ptr.h> namespace NMonitoring { - static const char HTTPOKTEXT[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/plain\r\nConnection: Close\r\n\r\n"; - static const char HTTPOKBIN[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/octet-stream\r\nConnection: Close\r\n\r\n"; - static const char HTTPOKHTML[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/html\r\nConnection: Close\r\n\r\n"; - static const char HTTPOKJSON[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/json\r\nConnection: Close\r\n\r\n"; - static const char HTTPOKSPACK[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/x-solomon-spack\r\nConnection: Close\r\n\r\n"; + static const char HTTPOKTEXT[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/plain\r\nConnection: Close\r\n\r\n"; + static const char HTTPOKBIN[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/octet-stream\r\nConnection: Close\r\n\r\n"; + static const char HTTPOKHTML[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/html\r\nConnection: Close\r\n\r\n"; + static const char HTTPOKJSON[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/json\r\nConnection: Close\r\n\r\n"; + static const char HTTPOKSPACK[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/x-solomon-spack\r\nConnection: Close\r\n\r\n"; static const char HTTPOKPROMETHEUS[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/plain\r\nConnection: Close\r\n\r\n"; - static const char HTTPOKJAVASCRIPT[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/javascript\r\nConnection: Close\r\n\r\n"; - static const char HTTPOKCSS[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/css\r\nConnection: Close\r\n\r\n"; - static const char HTTPNOCONTENT[] = "HTTP/1.1 204 No content\r\nConnection: Close\r\n\r\n"; - static const char HTTPNOTFOUND[] = "HTTP/1.1 404 Invalid URI\r\nConnection: Close\r\n\r\nInvalid URL\r\n"; + static const char HTTPOKJAVASCRIPT[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/javascript\r\nConnection: Close\r\n\r\n"; + static const char HTTPOKCSS[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/css\r\nConnection: Close\r\n\r\n"; + static const char HTTPNOCONTENT[] = "HTTP/1.1 204 No content\r\nConnection: Close\r\n\r\n"; + static const char HTTPNOTFOUND[] = "HTTP/1.1 404 Invalid URI\r\nConnection: Close\r\n\r\nInvalid URL\r\n"; static const char HTTPUNAUTHORIZED[] = "HTTP/1.1 401 Unauthorized\r\nConnection: Close\r\n\r\nUnauthorized\r\n"; static const char HTTPFORBIDDEN[] = "HTTP/1.1 403 Forbidden\r\nConnection: Close\r\n\r\nForbidden\r\n"; - // Fonts - static const char HTTPOKFONTEOT[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/vnd.ms-fontobject\r\nConnection: Close\r\n\r\n"; - static const char HTTPOKFONTTTF[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/x-font-ttf\r\nConnection: Close\r\n\r\n"; - static const char HTTPOKFONTWOFF[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/font-woff\r\nConnection: Close\r\n\r\n"; - static const char HTTPOKFONTWOFF2[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/font-woff2\r\nConnection: Close\r\n\r\n"; - - // Images - static const char HTTPOKPNG[] = "HTTP/1.1 200 Ok\r\nContent-Type: image/png\r\nConnection: Close\r\n\r\n"; - static const char HTTPOKSVG[] = "HTTP/1.1 200 Ok\r\nContent-Type: image/svg+xml\r\nConnection: Close\r\n\r\n"; + // Fonts + static const char HTTPOKFONTEOT[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/vnd.ms-fontobject\r\nConnection: Close\r\n\r\n"; + static const char HTTPOKFONTTTF[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/x-font-ttf\r\nConnection: Close\r\n\r\n"; + static const char HTTPOKFONTWOFF[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/font-woff\r\nConnection: Close\r\n\r\n"; + static const char HTTPOKFONTWOFF2[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/font-woff2\r\nConnection: Close\r\n\r\n"; - class IMonPage; + // Images + static const char HTTPOKPNG[] = "HTTP/1.1 200 Ok\r\nContent-Type: image/png\r\nConnection: Close\r\n\r\n"; + static const char HTTPOKSVG[] = "HTTP/1.1 200 Ok\r\nContent-Type: image/svg+xml\r\nConnection: Close\r\n\r\n"; - using TMonPagePtr = TIntrusivePtr<IMonPage>; + class IMonPage; - class IMonPage: public TAtomicRefCount<IMonPage> { - public: - const TString Path; - const TString Title; - const IMonPage* Parent = nullptr; + using TMonPagePtr = TIntrusivePtr<IMonPage>; - public: - IMonPage(const TString& path, const TString& title = TString()); + class IMonPage: public TAtomicRefCount<IMonPage> { + public: + const TString Path; + const TString Title; + const IMonPage* Parent = nullptr; - virtual ~IMonPage() { - } + public: + IMonPage(const TString& path, const TString& title = TString()); - void OutputNavBar(IOutputStream& out); + virtual ~IMonPage() { + } - virtual const TString& GetPath() const { - return Path; - } + void OutputNavBar(IOutputStream& out); + + virtual const TString& GetPath() const { + return Path; + } - virtual const TString& GetTitle() const { - return Title; - } + virtual const TString& GetTitle() const { + return Title; + } - bool IsInIndex() const { + bool IsInIndex() const { return !Title.empty(); - } + } virtual void Output(IMonHttpRequest& request) = 0; - }; + }; } diff --git a/library/cpp/monlib/service/pages/pre_mon_page.h b/library/cpp/monlib/service/pages/pre_mon_page.h index c9a923d39a..7f4199287d 100644 --- a/library/cpp/monlib/service/pages/pre_mon_page.h +++ b/library/cpp/monlib/service/pages/pre_mon_page.h @@ -3,25 +3,25 @@ #include "html_mon_page.h" namespace NMonitoring { - struct TPreMonPage: public THtmlMonPage { - TPreMonPage(const TString& path, - const TString& title = TString(), - bool preTag = true, - bool outputTableSorterJsCss = false) - : THtmlMonPage(path, title, outputTableSorterJsCss) - , PreTag(preTag) - { - } + struct TPreMonPage: public THtmlMonPage { + TPreMonPage(const TString& path, + const TString& title = TString(), + bool preTag = true, + bool outputTableSorterJsCss = false) + : THtmlMonPage(path, title, outputTableSorterJsCss) + , PreTag(preTag) + { + } void OutputContent(NMonitoring::IMonHttpRequest& request) override; - // hook to customize output + // hook to customize output virtual void BeforePre(NMonitoring::IMonHttpRequest& request); - // put your text here + // put your text here virtual void OutputText(IOutputStream& out, NMonitoring::IMonHttpRequest&) = 0; - const bool PreTag; - }; + const bool PreTag; + }; -} +} diff --git a/library/cpp/monlib/service/pages/registry_mon_page.cpp b/library/cpp/monlib/service/pages/registry_mon_page.cpp index c59e50f622..e05c80d07f 100644 --- a/library/cpp/monlib/service/pages/registry_mon_page.cpp +++ b/library/cpp/monlib/service/pages/registry_mon_page.cpp @@ -1,18 +1,18 @@ #include "registry_mon_page.h" -#include <library/cpp/monlib/encode/text/text.h> -#include <library/cpp/monlib/encode/json/json.h> +#include <library/cpp/monlib/encode/text/text.h> +#include <library/cpp/monlib/encode/json/json.h> #include <library/cpp/monlib/encode/prometheus/prometheus.h> -#include <library/cpp/monlib/encode/spack/spack_v1.h> +#include <library/cpp/monlib/encode/spack/spack_v1.h> #include <library/cpp/monlib/service/format.h> namespace NMonitoring { - void TMetricRegistryPage::Output(NMonitoring::IMonHttpRequest& request) { + void TMetricRegistryPage::Output(NMonitoring::IMonHttpRequest& request) { const auto formatStr = TStringBuf{request.GetPathInfo()}.RNextTok('/'); auto& out = request.Output(); if (!formatStr.empty()) { - IMetricEncoderPtr encoder; + IMetricEncoderPtr encoder; TString resp; if (formatStr == TStringBuf("json")) { @@ -26,7 +26,7 @@ namespace NMonitoring { resp = HTTPOKPROMETHEUS; encoder = NMonitoring::EncoderPrometheus(&out); } else { - ythrow yexception() << "unsupported metric encoding format: " << formatStr; + ythrow yexception() << "unsupported metric encoding format: " << formatStr; } out.Write(resp); @@ -38,8 +38,8 @@ namespace NMonitoring { } } - void TMetricRegistryPage::OutputText(IOutputStream& out, NMonitoring::IMonHttpRequest&) { - IMetricEncoderPtr encoder = NMonitoring::EncoderText(&out); + void TMetricRegistryPage::OutputText(IOutputStream& out, NMonitoring::IMonHttpRequest&) { + IMetricEncoderPtr encoder = NMonitoring::EncoderText(&out); RegistryRawPtr_->Accept(TInstant::Zero(), encoder.Get()); } diff --git a/library/cpp/monlib/service/pages/registry_mon_page.h b/library/cpp/monlib/service/pages/registry_mon_page.h index 2d26d3319c..c370dfc97b 100644 --- a/library/cpp/monlib/service/pages/registry_mon_page.h +++ b/library/cpp/monlib/service/pages/registry_mon_page.h @@ -2,11 +2,11 @@ #include "pre_mon_page.h" -#include <library/cpp/monlib/metrics/metric_registry.h> +#include <library/cpp/monlib/metrics/metric_registry.h> namespace NMonitoring { // For now this class can only enumerate all metrics without any grouping or serve JSON/Spack/Prometheus - class TMetricRegistryPage: public TPreMonPage { + class TMetricRegistryPage: public TPreMonPage { public: TMetricRegistryPage(const TString& path, const TString& title, TAtomicSharedPtr<IMetricSupplier> registry) : TPreMonPage(path, title) diff --git a/library/cpp/monlib/service/pages/resource_mon_page.cpp b/library/cpp/monlib/service/pages/resource_mon_page.cpp index ec4ac6a1a7..b8f7c73b25 100644 --- a/library/cpp/monlib/service/pages/resource_mon_page.cpp +++ b/library/cpp/monlib/service/pages/resource_mon_page.cpp @@ -4,7 +4,7 @@ using namespace NMonitoring; void TResourceMonPage::Output(NMonitoring::IMonHttpRequest& request) { IOutputStream& out = request.Output(); - switch (ResourceType) { + switch (ResourceType) { case TEXT: out << HTTPOKTEXT; break; diff --git a/library/cpp/monlib/service/pages/resource_mon_page.h b/library/cpp/monlib/service/pages/resource_mon_page.h index f6ab67200e..43b1dfc9c4 100644 --- a/library/cpp/monlib/service/pages/resource_mon_page.h +++ b/library/cpp/monlib/service/pages/resource_mon_page.h @@ -5,39 +5,39 @@ #include <library/cpp/resource/resource.h> namespace NMonitoring { - struct TResourceMonPage: public IMonPage { - public: - enum EResourceType { - BINARY, - TEXT, - JSON, - CSS, - JAVASCRIPT, - - FONT_EOT, - FONT_TTF, - FONT_WOFF, - FONT_WOFF2, - - PNG, - SVG - }; - - TResourceMonPage(const TString& path, const TString& resourceName, - const EResourceType& resourceType = BINARY) - : IMonPage(path, "") - , ResourceName(resourceName) - , ResourceType(resourceType) - { - } + struct TResourceMonPage: public IMonPage { + public: + enum EResourceType { + BINARY, + TEXT, + JSON, + CSS, + JAVASCRIPT, + + FONT_EOT, + FONT_TTF, + FONT_WOFF, + FONT_WOFF2, + + PNG, + SVG + }; + + TResourceMonPage(const TString& path, const TString& resourceName, + const EResourceType& resourceType = BINARY) + : IMonPage(path, "") + , ResourceName(resourceName) + , ResourceType(resourceType) + { + } void Output(NMonitoring::IMonHttpRequest& request) override; void NotFound(NMonitoring::IMonHttpRequest& request) const; - private: - TString ResourceName; - EResourceType ResourceType; - }; + private: + TString ResourceName; + EResourceType ResourceType; + }; -} +} diff --git a/library/cpp/monlib/service/pages/tablesorter/css_mon_page.h b/library/cpp/monlib/service/pages/tablesorter/css_mon_page.h index c2c8330089..abd1ed27b5 100644 --- a/library/cpp/monlib/service/pages/tablesorter/css_mon_page.h +++ b/library/cpp/monlib/service/pages/tablesorter/css_mon_page.h @@ -1,13 +1,13 @@ #pragma once -#include <library/cpp/monlib/service/pages/resource_mon_page.h> +#include <library/cpp/monlib/service/pages/resource_mon_page.h> namespace NMonitoring { - struct TTablesorterCssMonPage: public TResourceMonPage { - TTablesorterCssMonPage() - : TResourceMonPage("jquery.tablesorter.css", "jquery.tablesorter.css", CSS) - { - } - }; + struct TTablesorterCssMonPage: public TResourceMonPage { + TTablesorterCssMonPage() + : TResourceMonPage("jquery.tablesorter.css", "jquery.tablesorter.css", CSS) + { + } + }; -} +} diff --git a/library/cpp/monlib/service/pages/tablesorter/js_mon_page.h b/library/cpp/monlib/service/pages/tablesorter/js_mon_page.h index f8a1d8254e..79a1a2f667 100644 --- a/library/cpp/monlib/service/pages/tablesorter/js_mon_page.h +++ b/library/cpp/monlib/service/pages/tablesorter/js_mon_page.h @@ -1,13 +1,13 @@ #pragma once -#include <library/cpp/monlib/service/pages/resource_mon_page.h> +#include <library/cpp/monlib/service/pages/resource_mon_page.h> namespace NMonitoring { - struct TTablesorterJsMonPage: public TResourceMonPage { - TTablesorterJsMonPage() - : TResourceMonPage("jquery.tablesorter.js", "jquery.tablesorter.js", JAVASCRIPT) - { - } - }; + struct TTablesorterJsMonPage: public TResourceMonPage { + TTablesorterJsMonPage() + : TResourceMonPage("jquery.tablesorter.js", "jquery.tablesorter.js", JAVASCRIPT) + { + } + }; -} +} diff --git a/library/cpp/monlib/service/pages/tablesorter/ya.make b/library/cpp/monlib/service/pages/tablesorter/ya.make index b5b6a64da8..a07e43750a 100644 --- a/library/cpp/monlib/service/pages/tablesorter/ya.make +++ b/library/cpp/monlib/service/pages/tablesorter/ya.make @@ -8,7 +8,7 @@ RESOURCE( ) PEERDIR( - library/cpp/monlib/dynamic_counters + library/cpp/monlib/dynamic_counters ) END() diff --git a/library/cpp/monlib/service/pages/templates.cpp b/library/cpp/monlib/service/pages/templates.cpp index ece12bea71..17442c8c9b 100644 --- a/library/cpp/monlib/service/pages/templates.cpp +++ b/library/cpp/monlib/service/pages/templates.cpp @@ -32,4 +32,4 @@ namespace NMonitoring { extern const char DTermTag[] = "dt"; extern const char DDescTag[] = "dd"; -} +} diff --git a/library/cpp/monlib/service/pages/templates.h b/library/cpp/monlib/service/pages/templates.h index b4656f059f..356cd13483 100644 --- a/library/cpp/monlib/service/pages/templates.h +++ b/library/cpp/monlib/service/pages/templates.h @@ -7,76 +7,76 @@ #define WITH_SCOPED_I(var, value, label) \ if (auto var = (value)) { \ - Y_UNUSED(var); \ - goto label; \ - } else \ - label \ - : - -#define TAG(name) WITH_SCOPED(tmp, NMonitoring::name(__stream)) -#define TAG_CLASS(name, cls) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls)) -#define TAG_CLASS_STYLE(name, cls, style) WITH_SCOPED(tmp, NMonitoring::name(__stream, {{"class", cls}, {"style", style}})) -#define TAG_CLASS_ID(name, cls, id) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls, "", id)) -#define TAG_CLASS_FOR(name, cls, for0) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls, for0)) -#define TAG_ATTRS(name, ...) WITH_SCOPED(tmp, NMonitoring::name(__stream, ##__VA_ARGS__)) - -#define HTML(str) WITH_SCOPED(__stream, NMonitoring::TOutputStreamRef(str)) - -#define HEAD() TAG(THead) -#define BODY() TAG(TBody) -#define HTML_TAG() TAG(THtml) -#define DIV() TAG(TDiv) -#define DIV_CLASS(cls) TAG_CLASS(TDiv, cls) + Y_UNUSED(var); \ + goto label; \ + } else \ + label \ + : + +#define TAG(name) WITH_SCOPED(tmp, NMonitoring::name(__stream)) +#define TAG_CLASS(name, cls) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls)) +#define TAG_CLASS_STYLE(name, cls, style) WITH_SCOPED(tmp, NMonitoring::name(__stream, {{"class", cls}, {"style", style}})) +#define TAG_CLASS_ID(name, cls, id) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls, "", id)) +#define TAG_CLASS_FOR(name, cls, for0) WITH_SCOPED(tmp, NMonitoring::name(__stream, cls, for0)) +#define TAG_ATTRS(name, ...) WITH_SCOPED(tmp, NMonitoring::name(__stream, ##__VA_ARGS__)) + +#define HTML(str) WITH_SCOPED(__stream, NMonitoring::TOutputStreamRef(str)) + +#define HEAD() TAG(THead) +#define BODY() TAG(TBody) +#define HTML_TAG() TAG(THtml) +#define DIV() TAG(TDiv) +#define DIV_CLASS(cls) TAG_CLASS(TDiv, cls) #define DIV_CLASS_ID(cls, id) TAG_CLASS_ID(TDiv, cls, id) -#define PRE() TAG(TPre) -#define TABLE() TAG(TTable) -#define TABLE_CLASS(cls) TAG_CLASS(TTable, cls) -#define TABLE_SORTABLE() TABLE_CLASS("table-sortable") +#define PRE() TAG(TPre) +#define TABLE() TAG(TTable) +#define TABLE_CLASS(cls) TAG_CLASS(TTable, cls) +#define TABLE_SORTABLE() TABLE_CLASS("table-sortable") #define TABLE_SORTABLE_CLASS(cls) TABLE_CLASS(cls " table-sortable") -#define TABLEHEAD() TAG(TTableHead) -#define TABLEHEAD_CLASS(cls) TAG_CLASS(TTableHead, cls) -#define TABLEBODY() TAG(TTableBody) -#define TABLEBODY_CLASS(cls) TAG_CLASS(TTableBody, cls) -#define TABLER() TAG(TTableR) -#define TABLER_CLASS(cls) TAG_CLASS(TTableR, cls) -#define TABLED() TAG(TTableD) -#define TABLED_CLASS(cls) TAG_CLASS(TTableD, cls) -#define TABLED_ATTRS(...) TAG_ATTRS(TTableD, ##__VA_ARGS__) -#define TABLEH() TAG(TTableH) -#define TABLEH_CLASS(cls) TAG_CLASS(TTableH, cls) -#define FORM() TAG(TFormC) -#define FORM_CLASS(cls) TAG_CLASS(TFormC, cls) -#define LABEL() TAG(TLabelC) -#define LABEL_CLASS(cls) TAG_CLASS(TLabelC, cls) +#define TABLEHEAD() TAG(TTableHead) +#define TABLEHEAD_CLASS(cls) TAG_CLASS(TTableHead, cls) +#define TABLEBODY() TAG(TTableBody) +#define TABLEBODY_CLASS(cls) TAG_CLASS(TTableBody, cls) +#define TABLER() TAG(TTableR) +#define TABLER_CLASS(cls) TAG_CLASS(TTableR, cls) +#define TABLED() TAG(TTableD) +#define TABLED_CLASS(cls) TAG_CLASS(TTableD, cls) +#define TABLED_ATTRS(...) TAG_ATTRS(TTableD, ##__VA_ARGS__) +#define TABLEH() TAG(TTableH) +#define TABLEH_CLASS(cls) TAG_CLASS(TTableH, cls) +#define FORM() TAG(TFormC) +#define FORM_CLASS(cls) TAG_CLASS(TFormC, cls) +#define LABEL() TAG(TLabelC) +#define LABEL_CLASS(cls) TAG_CLASS(TLabelC, cls) #define LABEL_CLASS_FOR(cls, for0) TAG_CLASS_FOR(TLabelC, cls, for0) -#define SPAN_CLASS(cls) TAG_CLASS(TSpanC, cls) +#define SPAN_CLASS(cls) TAG_CLASS(TSpanC, cls) #define SPAN_CLASS_STYLE(cls, style) TAG_CLASS_STYLE(TSpanC, cls, style) -#define PARA() TAG(TPara) -#define PARA_CLASS(cls) TAG_CLASS(TPara, cls) - -#define H1() TAG(TH1) -#define H1_CLASS(cls) TAG_CLASS(TH1, cls) -#define H2() TAG(TH2) -#define H2_CLASS(cls) TAG_CLASS(TH2, cls) -#define H3() TAG(TH3) -#define H3_CLASS(cls) TAG_CLASS(TH3, cls) -#define H4() TAG(TH4) -#define H4_CLASS(cls) TAG_CLASS(TH4, cls) -#define H5() TAG(TH5) -#define H5_CLASS(cls) TAG_CLASS(TH5, cls) -#define H6() TAG(TH6) -#define H6_CLASS(cls) TAG_CLASS(TH6, cls) - -#define SMALL() TAG(TSMALL) -#define STRONG() TAG(TSTRONG) - -#define LI() TAG(TLIST) -#define LI_CLASS(cls) TAG_CLASS(TLIST, cls) -#define UL() TAG(TULIST) -#define UL_CLASS(cls) TAG_CLASS(TULIST, cls) -#define OL() TAG(TOLIST) -#define OL_CLASS(cls) TAG_CLASS(TOLIST, cls) +#define PARA() TAG(TPara) +#define PARA_CLASS(cls) TAG_CLASS(TPara, cls) + +#define H1() TAG(TH1) +#define H1_CLASS(cls) TAG_CLASS(TH1, cls) +#define H2() TAG(TH2) +#define H2_CLASS(cls) TAG_CLASS(TH2, cls) +#define H3() TAG(TH3) +#define H3_CLASS(cls) TAG_CLASS(TH3, cls) +#define H4() TAG(TH4) +#define H4_CLASS(cls) TAG_CLASS(TH4, cls) +#define H5() TAG(TH5) +#define H5_CLASS(cls) TAG_CLASS(TH5, cls) +#define H6() TAG(TH6) +#define H6_CLASS(cls) TAG_CLASS(TH6, cls) + +#define SMALL() TAG(TSMALL) +#define STRONG() TAG(TSTRONG) + +#define LI() TAG(TLIST) +#define LI_CLASS(cls) TAG_CLASS(TLIST, cls) +#define UL() TAG(TULIST) +#define UL_CLASS(cls) TAG_CLASS(TULIST, cls) +#define OL() TAG(TOLIST) +#define OL_CLASS(cls) TAG_CLASS(TOLIST, cls) #define DL() TAG(DLIST) #define DL_CLASS(cls) TAG_CLASS(DLIST, cls) @@ -85,8 +85,8 @@ #define DD() TAG(DDESC) #define DD_CLASS(cls) TAG_CLASS(DDESC, cls) -#define CAPTION() TAG(TCaption) -#define CAPTION_CLASS(cls) CAPTION_CLASS(TCaption, cls) +#define CAPTION() TAG(TCaption) +#define CAPTION_CLASS(cls) CAPTION_CLASS(TCaption, cls) #define HTML_OUTPUT_PARAM(str, param) str << #param << ": " << param << "<br/>" #define HTML_OUTPUT_TIME_PARAM(str, param) str << #param << ": " << ToStringLocalTimeUpToSeconds(param) << "<br/>" @@ -116,9 +116,9 @@ namespace NMonitoring { IOutputStream& Str; }; - template <const char* tag> + template <const char* tag> struct TTag { - TTag(IOutputStream& str, TStringBuf cls = "", TStringBuf for0 = "", TStringBuf id = "") + TTag(IOutputStream& str, TStringBuf cls = "", TStringBuf for0 = "", TStringBuf id = "") : Str(str) { Str << "<" << tag; @@ -137,7 +137,7 @@ namespace NMonitoring { Str << ">"; } - TTag(IOutputStream& str, std::initializer_list<std::pair<TStringBuf, TStringBuf>> attributes) + TTag(IOutputStream& str, std::initializer_list<std::pair<TStringBuf, TStringBuf>> attributes) : Str(str) { Str << "<" << tag; @@ -152,20 +152,20 @@ namespace NMonitoring { ~TTag() { try { Str << "</" << tag << ">"; - } catch (...) { - } + } catch (...) { + } } explicit inline operator bool() const noexcept { return true; // just to work with WITH_SCOPED } - IOutputStream& Str; + IOutputStream& Str; }; // a nice class for creating collapsable regions of html output struct TCollapsedButton { - TCollapsedButton(IOutputStream& str, const TString& targetId, const TString& buttonText) + TCollapsedButton(IOutputStream& str, const TString& targetId, const TString& buttonText) : Str(str) { Str << "<button type='button' class='btn' data-toggle='collapse' data-target='#" << targetId << "'>" @@ -176,22 +176,22 @@ namespace NMonitoring { ~TCollapsedButton() { try { Str << "</div>"; - } catch (...) { - } + } catch (...) { + } } explicit inline operator bool() const noexcept { return true; // just to work with WITH_SCOPED } - IOutputStream& Str; + IOutputStream& Str; }; struct TOutputStreamRef { TOutputStreamRef(IOutputStream& str) : Str(str) - { - } + { + } inline operator IOutputStream&() noexcept { return Str; @@ -265,4 +265,4 @@ namespace NMonitoring { typedef TTag<DListTag> DLIST; typedef TTag<DTermTag> DTERM; typedef TTag<DDescTag> DDESC; -} +} diff --git a/library/cpp/monlib/service/pages/version_mon_page.h b/library/cpp/monlib/service/pages/version_mon_page.h index f7649947e4..1ccfc6698e 100644 --- a/library/cpp/monlib/service/pages/version_mon_page.h +++ b/library/cpp/monlib/service/pages/version_mon_page.h @@ -3,13 +3,13 @@ #include "pre_mon_page.h" namespace NMonitoring { - struct TVersionMonPage: public TPreMonPage { - TVersionMonPage(const TString& path = "ver", const TString& title = "Version") - : TPreMonPage(path, title) - { - } + struct TVersionMonPage: public TPreMonPage { + TVersionMonPage(const TString& path = "ver", const TString& title = "Version") + : TPreMonPage(path, title) + { + } void OutputText(IOutputStream& out, NMonitoring::IMonHttpRequest&) override; - }; + }; -} +} diff --git a/library/cpp/monlib/service/pages/ya.make b/library/cpp/monlib/service/pages/ya.make index 48d44a0838..b9b6ca5646 100644 --- a/library/cpp/monlib/service/pages/ya.make +++ b/library/cpp/monlib/service/pages/ya.make @@ -1,31 +1,31 @@ -LIBRARY() - +LIBRARY() + OWNER(g:solomon) - + NO_WSHADOW() -SRCS( - diag_mon_page.cpp - html_mon_page.cpp - index_mon_page.cpp - mon_page.cpp - pre_mon_page.cpp - resource_mon_page.cpp - templates.cpp - version_mon_page.cpp +SRCS( + diag_mon_page.cpp + html_mon_page.cpp + index_mon_page.cpp + mon_page.cpp + pre_mon_page.cpp + resource_mon_page.cpp + templates.cpp + version_mon_page.cpp registry_mon_page.cpp -) - -PEERDIR( +) + +PEERDIR( library/cpp/build_info library/cpp/malloc/api library/cpp/svnversion library/cpp/resource - library/cpp/monlib/service - library/cpp/monlib/encode/json - library/cpp/monlib/encode/text - library/cpp/monlib/encode/spack + library/cpp/monlib/service + library/cpp/monlib/encode/json + library/cpp/monlib/encode/text + library/cpp/monlib/encode/spack library/cpp/monlib/encode/prometheus -) - -END() +) + +END() |