aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/projectstore/httpprojectstore.cpp
diff options
context:
space:
mode:
authorzousar <[email protected]>2023-12-07 15:28:35 -0700
committerGitHub <[email protected]>2023-12-07 15:28:35 -0700
commitb8b4701ec0810b1ea7df4aaf824d26d2bfce73fa (patch)
tree531317314903da569eea099c4a07e721de659b93 /src/zenserver/projectstore/httpprojectstore.cpp
parentUpdate CHANGELOG.md (diff)
parentMerge branch 'main' into zs/get-all-chunk-infos (diff)
downloadzen-b8b4701ec0810b1ea7df4aaf824d26d2bfce73fa.tar.xz
zen-b8b4701ec0810b1ea7df4aaf824d26d2bfce73fa.zip
Merge pull request #593 from EpicGames/zs/get-all-chunk-infos
Zs/get all chunk infos
Diffstat (limited to 'src/zenserver/projectstore/httpprojectstore.cpp')
-rw-r--r--src/zenserver/projectstore/httpprojectstore.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/zenserver/projectstore/httpprojectstore.cpp b/src/zenserver/projectstore/httpprojectstore.cpp
index 261485834..0ba49cf8a 100644
--- a/src/zenserver/projectstore/httpprojectstore.cpp
+++ b/src/zenserver/projectstore/httpprojectstore.cpp
@@ -276,6 +276,11 @@ HttpProjectService::HttpProjectService(CidStore& Store, ProjectStore* Projects,
HttpVerb::kGet);
m_Router.RegisterRoute(
+ "{project}/oplog/{log}/chunkinfos",
+ [this](HttpRouterRequest& Req) { HandleChunkInfosRequest(Req); },
+ HttpVerb::kGet);
+
+ m_Router.RegisterRoute(
"{project}/oplog/{log}/{chunk}/info",
[this](HttpRouterRequest& Req) { HandleChunkInfoRequest(Req); },
HttpVerb::kGet);
@@ -643,6 +648,41 @@ HttpProjectService::HandleFilesRequest(HttpRouterRequest& Req)
}
void
+HttpProjectService::HandleChunkInfosRequest(HttpRouterRequest& Req)
+{
+ ZEN_TRACE_CPU("ProjectService::ChunkInfos");
+
+ HttpServerRequest& HttpReq = Req.ServerRequest();
+
+ const auto& ProjectId = Req.GetCapture(1);
+ const auto& OplogId = Req.GetCapture(2);
+
+ CbObject ResponsePayload;
+ std::pair<HttpResponseCode, std::string> Result = m_ProjectStore->GetProjectChunkInfos(ProjectId, OplogId, ResponsePayload);
+ if (Result.first == HttpResponseCode::OK)
+ {
+ return HttpReq.WriteResponse(HttpResponseCode::OK, ResponsePayload);
+ }
+ else
+ {
+ if (Result.first == HttpResponseCode::BadRequest)
+ {
+ m_ProjectStats.BadRequestCount++;
+ }
+ ZEN_DEBUG("Request {}: '{}' failed with {}. Reason: `{}`",
+ ToString(HttpReq.RequestVerb()),
+ HttpReq.QueryString(),
+ static_cast<int>(Result.first),
+ Result.second);
+ }
+ if (Result.second.empty())
+ {
+ return HttpReq.WriteResponse(Result.first);
+ }
+ return HttpReq.WriteResponse(Result.first, HttpContentType::kText, Result.second);
+}
+
+void
HttpProjectService::HandleChunkInfoRequest(HttpRouterRequest& Req)
{
ZEN_TRACE_CPU("ProjectService::ChunkInfo");