summaryrefslogtreecommitdiff
path: root/src/other_tools/ops_maps
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-06-11 16:07:50 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-06-18 12:05:10 +0200
commitec447408d17c530ce2023d8148dd34a6d8138535 (patch)
treec644991efe281d3a7fa91451fa2d4fa70884f763 /src/other_tools/ops_maps
parent651af149098289b60cdfb062d36eb435d8e49c52 (diff)
downloadjustbuild-ec447408d17c530ce2023d8148dd34a6d8138535.tar.gz
Pass ServeApi to just-mr maps by reference
...instead of using singleton calls.
Diffstat (limited to 'src/other_tools/ops_maps')
-rw-r--r--src/other_tools/ops_maps/TARGETS4
-rw-r--r--src/other_tools/ops_maps/content_cas_map.cpp11
-rw-r--r--src/other_tools/ops_maps/content_cas_map.hpp3
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.cpp12
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.hpp3
5 files changed, 16 insertions, 17 deletions
diff --git a/src/other_tools/ops_maps/TARGETS b/src/other_tools/ops_maps/TARGETS
index 94894e60..dcf58392 100644
--- a/src/other_tools/ops_maps/TARGETS
+++ b/src/other_tools/ops_maps/TARGETS
@@ -66,6 +66,7 @@
, ["src/other_tools/just_mr", "mirrors"]
, ["src/other_tools/ops_maps", "critical_git_op_map"]
, ["src/utils/cpp", "hash_combine"]
+ , ["src/buildtool/serve_api/remote", "serve_api"]
]
, "stage": ["src", "other_tools", "ops_maps"]
, "private-deps":
@@ -73,7 +74,6 @@
, ["src/other_tools/utils", "content"]
, ["src/buildtool/execution_api/local", "local"]
, ["src/buildtool/file_system", "file_storage"]
- , ["src/buildtool/serve_api/remote", "serve_api"]
, ["src/buildtool/storage", "config"]
, ["src/buildtool/storage", "fs_utils"]
, ["src/buildtool/storage", "storage"]
@@ -113,6 +113,7 @@
, ["src/buildtool/execution_api/common", "common"]
, ["src/other_tools/ops_maps", "critical_git_op_map"]
, ["src/other_tools/ops_maps", "import_to_git_map"]
+ , ["src/buildtool/serve_api/remote", "serve_api"]
]
, "stage": ["src", "other_tools", "ops_maps"]
, "private-deps":
@@ -122,7 +123,6 @@
, ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/file_system", "file_system_manager"]
, ["src/buildtool/multithreading", "task_system"]
- , ["src/buildtool/serve_api/remote", "serve_api"]
, ["src/buildtool/storage", "config"]
, ["src/buildtool/storage", "storage"]
, ["src/buildtool/system", "system_command"]
diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp
index 20d85b8a..527bd7de 100644
--- a/src/other_tools/ops_maps/content_cas_map.cpp
+++ b/src/other_tools/ops_maps/content_cas_map.cpp
@@ -18,7 +18,6 @@
#include "fmt/core.h"
#include "src/buildtool/file_system/file_storage.hpp"
-#include "src/buildtool/serve_api/remote/serve_api.hpp"
#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/fs_utils.hpp"
#include "src/buildtool/storage/storage.hpp"
@@ -109,7 +108,7 @@ auto CreateContentCASMap(
MirrorsPtr const& additional_mirrors,
CAInfoPtr const& ca_info,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
- bool serve_api_exists,
+ std::optional<gsl::not_null<const ServeApi*>> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
std::size_t jobs) -> ContentCASMap {
@@ -117,7 +116,7 @@ auto CreateContentCASMap(
additional_mirrors,
ca_info,
critical_git_op_map,
- serve_api_exists,
+ serve,
local_api,
remote_api](auto ts,
auto setter,
@@ -150,7 +149,7 @@ auto CreateContentCASMap(
just_mr_paths,
additional_mirrors,
ca_info,
- serve_api_exists,
+ serve,
local_api,
remote_api,
setter,
@@ -216,8 +215,8 @@ auto CreateContentCASMap(
return;
}
// check if content is known to remote serve service
- if (serve_api_exists and remote_api and
- ServeApi::Instance().ContentInRemoteCAS(key.content)) {
+ if (serve and remote_api and
+ (*serve)->ContentInRemoteCAS(key.content)) {
// try to get content from remote CAS
if (remote_api.value()->RetrieveToCas(
{Artifact::ObjectInfo{.digest = digest,
diff --git a/src/other_tools/ops_maps/content_cas_map.hpp b/src/other_tools/ops_maps/content_cas_map.hpp
index 63934b24..9e8d9f46 100644
--- a/src/other_tools/ops_maps/content_cas_map.hpp
+++ b/src/other_tools/ops_maps/content_cas_map.hpp
@@ -25,6 +25,7 @@
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/file_system/symlinks_map/pragma_special.hpp"
#include "src/buildtool/multithreading/async_map_consumer.hpp"
+#include "src/buildtool/serve_api/remote/serve_api.hpp"
#include "src/other_tools/just_mr/mirrors.hpp"
#include "src/other_tools/ops_maps/critical_git_op_map.hpp"
#include "src/utils/cpp/hash_combine.hpp"
@@ -83,7 +84,7 @@ using ContentCASMap = AsyncMapConsumer<ArchiveContent, std::nullptr_t>;
MirrorsPtr const& additional_mirrors,
CAInfoPtr const& ca_info,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
- bool serve_api_exists,
+ std::optional<gsl::not_null<const ServeApi*>> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
std::size_t jobs) -> ContentCASMap;
diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.cpp b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
index fec72b27..10095045 100644
--- a/src/other_tools/ops_maps/git_tree_fetch_map.cpp
+++ b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
@@ -24,7 +24,6 @@
#include "src/buildtool/execution_api/common/execution_common.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/multithreading/task_system.hpp"
-#include "src/buildtool/serve_api/remote/serve_api.hpp"
#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/storage.hpp"
#include "src/buildtool/system/system_command.hpp"
@@ -129,7 +128,7 @@ auto CreateGitTreeFetchMap(
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
std::string const& git_bin,
std::vector<std::string> const& launcher,
- bool serve_api_exists,
+ std::optional<gsl::not_null<const ServeApi*>> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
bool backup_to_remote,
@@ -138,7 +137,7 @@ auto CreateGitTreeFetchMap(
import_to_git_map,
git_bin,
launcher,
- serve_api_exists,
+ serve,
local_api,
remote_api,
backup_to_remote](auto ts,
@@ -164,7 +163,7 @@ auto CreateGitTreeFetchMap(
import_to_git_map,
git_bin,
launcher,
- serve_api_exists,
+ serve,
local_api,
remote_api,
backup_to_remote,
@@ -232,12 +231,11 @@ auto CreateGitTreeFetchMap(
JustMRProgress::Instance().TaskTracker().Start(key.origin);
// check if tree is known to remote serve service and can be
// made available in remote CAS
- if (serve_api_exists and remote_api) {
+ if (serve and remote_api) {
// as we anyway interrogate the remote execution endpoint,
// we're only interested here in the serve endpoint making
// an attempt to upload the tree, if known, to remote CAS
- std::ignore =
- ServeApi::Instance().TreeInRemoteCAS(key.hash);
+ std::ignore = (*serve)->TreeInRemoteCAS(key.hash);
}
// check if tree is in remote CAS, if a remote is given
if (remote_api and
diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.hpp b/src/other_tools/ops_maps/git_tree_fetch_map.hpp
index 05ad1c3c..3f6e6769 100644
--- a/src/other_tools/ops_maps/git_tree_fetch_map.hpp
+++ b/src/other_tools/ops_maps/git_tree_fetch_map.hpp
@@ -23,6 +23,7 @@
#include "gsl/gsl"
#include "src/buildtool/execution_api/common/execution_api.hpp"
+#include "src/buildtool/serve_api/remote/serve_api.hpp"
#include "src/other_tools/ops_maps/critical_git_op_map.hpp"
#include "src/other_tools/ops_maps/import_to_git_map.hpp"
@@ -59,7 +60,7 @@ using GitTreeFetchMap = AsyncMapConsumer<GitTreeInfo, bool>;
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
std::string const& git_bin,
std::vector<std::string> const& launcher,
- bool serve_api_exists,
+ std::optional<gsl::not_null<const ServeApi*>> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
bool backup_to_remote,