diff options
| author | Stefan Boberg <[email protected]> | 2021-10-04 15:24:53 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-10-04 15:25:33 +0200 |
| commit | cceed531be3fc89f034e79a599a72e28ebe7d32b (patch) | |
| tree | b53c473c3d9899bc97b0b90336882f37f8bcfcf3 | |
| parent | clang-format (diff) | |
| download | zen-cceed531be3fc89f034e79a599a72e28ebe7d32b.tar.xz zen-cceed531be3fc89f034e79a599a72e28ebe7d32b.zip | |
monitoring: added stubs for /stats and /status endpoints
this is a tactical check-in to allow me to merge some other changes
| -rw-r--r-- | zenserver/monitoring/httpstats.cpp | 33 | ||||
| -rw-r--r-- | zenserver/monitoring/httpstats.h | 26 | ||||
| -rw-r--r-- | zenserver/monitoring/httpstatus.cpp | 33 | ||||
| -rw-r--r-- | zenserver/monitoring/httpstatus.h | 26 | ||||
| -rw-r--r-- | zenserver/zenserver.vcxproj | 7 | ||||
| -rw-r--r-- | zenserver/zenserver.vcxproj.filters | 7 |
6 files changed, 132 insertions, 0 deletions
diff --git a/zenserver/monitoring/httpstats.cpp b/zenserver/monitoring/httpstats.cpp new file mode 100644 index 000000000..a82cfda50 --- /dev/null +++ b/zenserver/monitoring/httpstats.cpp @@ -0,0 +1,33 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#include "httpstats.h" + +namespace zen { + +HttpStatsService::HttpStatsService() : m_Log(logging::Get("stats")) +{ +} + +HttpStatsService::~HttpStatsService() +{ +} + +const char* +HttpStatsService::BaseUri() const +{ + return "/stats/"; +} + +void +HttpStatsService::HandleRequest(HttpServerRequest& Request) +{ + using namespace std::literals; + + switch (Request.RequestVerb()) + { + case HttpVerb::kGet: + return Request.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, u8"OK!"sv); + } +} + +} // namespace zen diff --git a/zenserver/monitoring/httpstats.h b/zenserver/monitoring/httpstats.h new file mode 100644 index 000000000..9da48233b --- /dev/null +++ b/zenserver/monitoring/httpstats.h @@ -0,0 +1,26 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include <zenhttp/httpserver.h> +#include <zencore/logging.h> + +namespace zen { + +class HttpStatsService : public HttpService +{ +public: + HttpStatsService(); + ~HttpStatsService(); + + virtual const char* BaseUri() const override; + virtual void HandleRequest(HttpServerRequest& Request) override; + +private: + spdlog::logger& m_Log; + HttpRequestRouter m_Router; + + inline spdlog::logger& Log() { return m_Log; } +}; + +} // namespace zen
\ No newline at end of file diff --git a/zenserver/monitoring/httpstatus.cpp b/zenserver/monitoring/httpstatus.cpp new file mode 100644 index 000000000..c18bf6c1f --- /dev/null +++ b/zenserver/monitoring/httpstatus.cpp @@ -0,0 +1,33 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#include "httpstatus.h" + +namespace zen { + +HttpStatusService::HttpStatusService() : m_Log(logging::Get("status")) +{ +} + +HttpStatusService::~HttpStatusService() +{ +} + +const char* +HttpStatusService::BaseUri() const +{ + return "/statUs/"; +} + +void +HttpStatusService::HandleRequest(HttpServerRequest& Request) +{ + using namespace std::literals; + + switch (Request.RequestVerb()) + { + case HttpVerb::kGet: + return Request.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, u8"OK!"sv); + } +} + +} // namespace zen diff --git a/zenserver/monitoring/httpstatus.h b/zenserver/monitoring/httpstatus.h new file mode 100644 index 000000000..f5c6bd616 --- /dev/null +++ b/zenserver/monitoring/httpstatus.h @@ -0,0 +1,26 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include <zenhttp/httpserver.h> +#include <zencore/logging.h> + +namespace zen { + +class HttpStatusService : public HttpService +{ +public: + HttpStatusService(); + ~HttpStatusService(); + + virtual const char* BaseUri() const override; + virtual void HandleRequest(HttpServerRequest& Request) override; + +private: + spdlog::logger& m_Log; + HttpRequestRouter m_Router; + + inline spdlog::logger& Log() { return m_Log; } +}; + +} // namespace zen
\ No newline at end of file diff --git a/zenserver/zenserver.vcxproj b/zenserver/zenserver.vcxproj index 335786fbf..7fad477a1 100644 --- a/zenserver/zenserver.vcxproj +++ b/zenserver/zenserver.vcxproj @@ -108,8 +108,12 @@ <ClInclude Include="cache\structuredcachestore.h" /> <ClInclude Include="compute\apply.h" /> <ClInclude Include="config.h" /> + <ClInclude Include="diag\formatters.h" /> <ClInclude Include="diag\logging.h" /> <ClInclude Include="experimental\frontend.h" /> + <ClInclude Include="experimental\vfs.h" /> + <ClInclude Include="monitoring\httpstats.h" /> + <ClInclude Include="monitoring\httpstatus.h" /> <ClInclude Include="resource.h" /> <ClInclude Include="sos\sos.h" /> <ClInclude Include="testing\httptest.h" /> @@ -134,6 +138,9 @@ <ClCompile Include="config.cpp" /> <ClCompile Include="diag\logging.cpp" /> <ClCompile Include="experimental\frontend.cpp" /> + <ClCompile Include="experimental\vfs.cpp" /> + <ClCompile Include="monitoring\httpstats.cpp" /> + <ClCompile Include="monitoring\httpstatus.cpp" /> <ClCompile Include="projectstore.cpp" /> <ClCompile Include="cache\cacheagent.cpp" /> <ClCompile Include="sos\sos.cpp" /> diff --git a/zenserver/zenserver.vcxproj.filters b/zenserver/zenserver.vcxproj.filters index 1c5b17fee..04e639a33 100644 --- a/zenserver/zenserver.vcxproj.filters +++ b/zenserver/zenserver.vcxproj.filters @@ -41,6 +41,10 @@ <ClInclude Include="experimental\frontend.h"> <Filter>experimental</Filter> </ClInclude> + <ClInclude Include="diag\formatters.h" /> + <ClInclude Include="experimental\vfs.h" /> + <ClInclude Include="monitoring\httpstats.h" /> + <ClInclude Include="monitoring\httpstatus.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="zenserver.cpp" /> @@ -77,6 +81,9 @@ <ClCompile Include="experimental\frontend.cpp"> <Filter>experimental</Filter> </ClCompile> + <ClCompile Include="experimental\vfs.cpp" /> + <ClCompile Include="monitoring\httpstats.cpp" /> + <ClCompile Include="monitoring\httpstatus.cpp" /> </ItemGroup> <ItemGroup> <Filter Include="cache"> |