summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildtool/build_engine/target_map/absent_target_map.cpp5
-rw-r--r--src/buildtool/build_engine/target_map/export.cpp3
-rw-r--r--src/buildtool/build_engine/target_map/target_map.cpp2
-rw-r--r--src/buildtool/main/describe.cpp4
-rw-r--r--src/buildtool/serve_api/remote/serve_api.hpp89
-rw-r--r--src/other_tools/just_mr/fetch.cpp4
-rw-r--r--src/other_tools/just_mr/setup.cpp4
-rw-r--r--src/other_tools/ops_maps/content_cas_map.cpp2
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.cpp5
-rw-r--r--src/other_tools/root_maps/commit_git_map.cpp24
-rw-r--r--src/other_tools/root_maps/content_git_map.cpp24
-rw-r--r--src/other_tools/root_maps/distdir_git_map.cpp17
-rw-r--r--src/other_tools/root_maps/foreign_file_git_map.cpp2
-rw-r--r--src/other_tools/root_maps/root_utils.cpp4
14 files changed, 98 insertions, 91 deletions
diff --git a/src/buildtool/build_engine/target_map/absent_target_map.cpp b/src/buildtool/build_engine/target_map/absent_target_map.cpp
index 6cff055d..fca75194 100644
--- a/src/buildtool/build_engine/target_map/absent_target_map.cpp
+++ b/src/buildtool/build_engine/target_map/absent_target_map.cpp
@@ -85,7 +85,8 @@ void WithFlexibleVariables(
task,
key.target.ToString());
exports_progress->TaskTracker().Start(task);
- auto res = ServeApi::ServeTarget(*target_cache_key, *repo_key);
+ auto res =
+ ServeApi::Instance().ServeTarget(*target_cache_key, *repo_key);
// process response from serve endpoint
if (not res) {
// report target not found
@@ -199,7 +200,7 @@ auto BuildMaps::Target::CreateAbsentTargetVariablesMap(std::size_t jobs)
auto logger,
auto /*subcaller*/,
auto key) {
- auto flexible_vars_opt = ServeApi::ServeTargetVariables(
+ auto flexible_vars_opt = ServeApi::Instance().ServeTargetVariables(
key.target_root_id, key.target_file, key.target);
if (!flexible_vars_opt) {
(*logger)(fmt::format("Failed to obtain flexible config variables "
diff --git a/src/buildtool/build_engine/target_map/export.cpp b/src/buildtool/build_engine/target_map/export.cpp
index 719223e5..96e2d299 100644
--- a/src/buildtool/build_engine/target_map/export.cpp
+++ b/src/buildtool/build_engine/target_map/export.cpp
@@ -151,7 +151,8 @@ void ExportRule(
key.target.ToString(),
PruneJson(effective_config.ToJson()).dump());
exports_progress->TaskTracker().Start(task);
- auto res = ServeApi::ServeTarget(*target_cache_key, *repo_key);
+ auto res =
+ ServeApi::Instance().ServeTarget(*target_cache_key, *repo_key);
// process response from serve endpoint
if (not res) {
// target not found: log to performance, and continue
diff --git a/src/buildtool/build_engine/target_map/target_map.cpp b/src/buildtool/build_engine/target_map/target_map.cpp
index 8d904ff8..423835d3 100644
--- a/src/buildtool/build_engine/target_map/target_map.cpp
+++ b/src/buildtool/build_engine/target_map/target_map.cpp
@@ -1924,7 +1924,7 @@ auto CreateTargetMap(
/*is_fatal=*/true);
return;
}
- if (not ServeApi::CheckServeRemoteExecution()) {
+ if (not ServeApi::Instance().CheckServeRemoteExecution()) {
(*logger)(
"Inconsistent remote execution endpoint and serve endpoint"
"configuration detected.",
diff --git a/src/buildtool/main/describe.cpp b/src/buildtool/main/describe.cpp
index 1fb861d5..eb70f076 100644
--- a/src/buildtool/main/describe.cpp
+++ b/src/buildtool/main/describe.cpp
@@ -285,7 +285,7 @@ auto DescribeTarget(BuildMaps::Target::ConfiguredTarget const& id,
// check that just serve and the client use same remote execution
// endpoint; it might make sense in the future to remove or avoid this
// check, e.g., if remote endpoints are behind proxies.
- if (not ServeApi::CheckServeRemoteExecution()) {
+ if (not ServeApi::Instance().CheckServeRemoteExecution()) {
Logger::Log(LogLevel::Error,
"Inconsistent remote execution endpoint and serve "
"endpoint configuration detected.");
@@ -302,7 +302,7 @@ auto DescribeTarget(BuildMaps::Target::ConfiguredTarget const& id,
repo_name);
return kExitFailure;
}
- if (auto dgst = ServeApi::ServeTargetDescription(
+ if (auto dgst = ServeApi::Instance().ServeTargetDescription(
*target_root_id,
*(repo_config->TargetFileName(repo_name)),
id.target.GetNamedTarget().name)) {
diff --git a/src/buildtool/serve_api/remote/serve_api.hpp b/src/buildtool/serve_api/remote/serve_api.hpp
index 83b2f9d0..4717c8a0 100644
--- a/src/buildtool/serve_api/remote/serve_api.hpp
+++ b/src/buildtool/serve_api/remote/serve_api.hpp
@@ -42,86 +42,85 @@ class ServeApi final {
return instance;
}
- [[nodiscard]] static auto RetrieveTreeFromCommit(
- std::string const& commit,
- std::string const& subdir = ".",
- bool sync_tree = false) noexcept -> std::variant<bool, std::string> {
- return Instance().stc_->ServeCommitTree(commit, subdir, sync_tree);
+ [[nodiscard]] auto RetrieveTreeFromCommit(std::string const& commit,
+ std::string const& subdir = ".",
+ bool sync_tree = false)
+ const noexcept -> std::variant<bool, std::string> {
+ return stc_->ServeCommitTree(commit, subdir, sync_tree);
}
- [[nodiscard]] static auto RetrieveTreeFromArchive(
+ [[nodiscard]] auto RetrieveTreeFromArchive(
std::string const& content,
std::string const& archive_type = "archive",
std::string const& subdir = ".",
std::optional<PragmaSpecial> const& resolve_symlinks = std::nullopt,
- bool sync_tree = false) noexcept -> std::variant<bool, std::string> {
- return Instance().stc_->ServeArchiveTree(
+ bool sync_tree = false) const noexcept
+ -> std::variant<bool, std::string> {
+ return stc_->ServeArchiveTree(
content, archive_type, subdir, resolve_symlinks, sync_tree);
}
- [[nodiscard]] static auto RetrieveTreeFromDistdir(
+ [[nodiscard]] auto RetrieveTreeFromDistdir(
std::shared_ptr<std::unordered_map<std::string, std::string>> const&
distfiles,
- bool sync_tree = false) noexcept -> std::variant<bool, std::string> {
- return Instance().stc_->ServeDistdirTree(distfiles, sync_tree);
+ bool sync_tree = false) const noexcept
+ -> std::variant<bool, std::string> {
+ return stc_->ServeDistdirTree(distfiles, sync_tree);
}
- [[nodiscard]] static auto RetrieveTreeFromForeignFile(
+ [[nodiscard]] auto RetrieveTreeFromForeignFile(
const std::string& content,
const std::string& name,
- bool executable) noexcept -> std::variant<bool, std::string> {
- return Instance().stc_->ServeForeignFileTree(content, name, executable);
+ bool executable) const noexcept -> std::variant<bool, std::string> {
+ return stc_->ServeForeignFileTree(content, name, executable);
}
- [[nodiscard]] static auto ContentInRemoteCAS(
- std::string const& content) noexcept -> bool {
- return Instance().stc_->ServeContent(content);
+ [[nodiscard]] auto ContentInRemoteCAS(
+ std::string const& content) const noexcept -> bool {
+ return stc_->ServeContent(content);
}
- [[nodiscard]] static auto TreeInRemoteCAS(
- std::string const& tree_id) noexcept -> bool {
- return Instance().stc_->ServeTree(tree_id);
+ [[nodiscard]] auto TreeInRemoteCAS(
+ std::string const& tree_id) const noexcept -> bool {
+ return stc_->ServeTree(tree_id);
}
- [[nodiscard]] static auto CheckRootTree(std::string const& tree_id) noexcept
+ [[nodiscard]] auto CheckRootTree(std::string const& tree_id) const noexcept
-> std::optional<bool> {
- return Instance().stc_->CheckRootTree(tree_id);
+ return stc_->CheckRootTree(tree_id);
}
- [[nodiscard]] static auto GetTreeFromRemote(
- std::string const& tree_id) noexcept -> bool {
- return Instance().stc_->GetRemoteTree(tree_id);
+ [[nodiscard]] auto GetTreeFromRemote(
+ std::string const& tree_id) const noexcept -> bool {
+ return stc_->GetRemoteTree(tree_id);
}
- [[nodiscard]] static auto ServeTargetVariables(
- std::string const& target_root_id,
- std::string const& target_file,
- std::string const& target) noexcept
- -> std::optional<std::vector<std::string>> {
- return Instance().tc_->ServeTargetVariables(
- target_root_id, target_file, target);
+ [[nodiscard]] auto ServeTargetVariables(std::string const& target_root_id,
+ std::string const& target_file,
+ std::string const& target)
+ const noexcept -> std::optional<std::vector<std::string>> {
+ return tc_->ServeTargetVariables(target_root_id, target_file, target);
}
- [[nodiscard]] static auto ServeTargetDescription(
- std::string const& target_root_id,
- std::string const& target_file,
- std::string const& target) noexcept -> std::optional<ArtifactDigest> {
- return Instance().tc_->ServeTargetDescription(
- target_root_id, target_file, target);
+ [[nodiscard]] auto ServeTargetDescription(std::string const& target_root_id,
+ std::string const& target_file,
+ std::string const& target)
+ const noexcept -> std::optional<ArtifactDigest> {
+ return tc_->ServeTargetDescription(target_root_id, target_file, target);
}
- [[nodiscard]] static auto ServeTarget(const TargetCacheKey& key,
- const std::string& repo_key) noexcept
+ [[nodiscard]] auto ServeTarget(const TargetCacheKey& key,
+ const std::string& repo_key) const noexcept
-> std::optional<serve_target_result_t> {
- return Instance().tc_->ServeTarget(key, repo_key);
+ return tc_->ServeTarget(key, repo_key);
}
- [[nodiscard]] static auto CheckServeRemoteExecution() noexcept -> bool {
- return Instance().cc_->CheckServeRemoteExecution();
+ [[nodiscard]] auto CheckServeRemoteExecution() const noexcept -> bool {
+ return cc_->CheckServeRemoteExecution();
}
- [[nodiscard]] static auto IsCompatible() noexcept -> std::optional<bool> {
- return Instance().cc_->IsCompatible();
+ [[nodiscard]] auto IsCompatible() const noexcept -> std::optional<bool> {
+ return cc_->IsCompatible();
}
private:
diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp
index f2c3e8a9..46be0083 100644
--- a/src/other_tools/just_mr/fetch.cpp
+++ b/src/other_tools/just_mr/fetch.cpp
@@ -404,7 +404,7 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
// check configuration of the serve endpoint provided
if (serve_api_exists) {
// check the compatibility mode of the serve endpoint
- auto compatible = ServeApi::IsCompatible();
+ auto compatible = ServeApi::Instance().IsCompatible();
if (not compatible) {
Logger::Log(LogLevel::Warning,
"Checking compatibility configuration of the provided "
@@ -421,7 +421,7 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
// if we have a remote endpoint explicitly given by the user, it must
// match what the serve endpoint expects
if (remote_api and common_args.remote_execution_address and
- not ServeApi::CheckServeRemoteExecution()) {
+ not ServeApi::Instance().CheckServeRemoteExecution()) {
return kExitFetchError; // this check logs error on failure
}
}
diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp
index 0479d0e5..2d60a8da 100644
--- a/src/other_tools/just_mr/setup.cpp
+++ b/src/other_tools/just_mr/setup.cpp
@@ -123,7 +123,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
// check configuration of the serve endpoint provided
if (serve_api_exists) {
// check the compatibility mode of the serve endpoint
- auto compatible = ServeApi::IsCompatible();
+ auto compatible = ServeApi::Instance().IsCompatible();
if (not compatible) {
Logger::Log(LogLevel::Warning,
"Checking compatibility configuration of the provided "
@@ -140,7 +140,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
// if we have a remote endpoint explicitly given by the user, it must
// match what the serve endpoint expects
if (remote_api and common_args.remote_execution_address and
- not ServeApi::CheckServeRemoteExecution()) {
+ not ServeApi::Instance().CheckServeRemoteExecution()) {
return std::nullopt; // this check logs error on failure
}
}
diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp
index a8d2eebf..20d85b8a 100644
--- a/src/other_tools/ops_maps/content_cas_map.cpp
+++ b/src/other_tools/ops_maps/content_cas_map.cpp
@@ -217,7 +217,7 @@ auto CreateContentCASMap(
}
// check if content is known to remote serve service
if (serve_api_exists and remote_api and
- ServeApi::ContentInRemoteCAS(key.content)) {
+ ServeApi::Instance().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/git_tree_fetch_map.cpp b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
index 743ba7f7..fec72b27 100644
--- a/src/other_tools/ops_maps/git_tree_fetch_map.cpp
+++ b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
@@ -15,6 +15,7 @@
#include "src/other_tools/ops_maps/git_tree_fetch_map.hpp"
#include <cstdlib>
+#include <tuple> // std::ignore
#include <utility> // std::move
#include "fmt/core.h"
@@ -235,8 +236,8 @@ auto CreateGitTreeFetchMap(
// 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
- [[maybe_unused]] auto _ =
- ServeApi::TreeInRemoteCAS(key.hash);
+ std::ignore =
+ ServeApi::Instance().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/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp
index 913a7e15..b6dac07a 100644
--- a/src/other_tools/root_maps/commit_git_map.cpp
+++ b/src/other_tools/root_maps/commit_git_map.cpp
@@ -77,10 +77,10 @@ void EnsureRootAsAbsent(
if (not *has_tree) {
// try to see if serve endpoint has the information to prepare the
// root itself
- auto serve_result =
- ServeApi::RetrieveTreeFromCommit(repo_info.hash,
- repo_info.subdir,
- /*sync_tree = */ false);
+ auto serve_result = ServeApi::Instance().RetrieveTreeFromCommit(
+ repo_info.hash,
+ repo_info.subdir,
+ /*sync_tree = */ false);
if (std::holds_alternative<std::string>(serve_result)) {
// if serve has set up the tree, it must match what we expect
auto const& served_tree_id =
@@ -513,10 +513,10 @@ void EnsureCommit(
if (serve_api_exists) {
// if root purely absent, request only the subdir tree
if (repo_info.absent and not fetch_absent) {
- auto serve_result =
- ServeApi::RetrieveTreeFromCommit(repo_info.hash,
- repo_info.subdir,
- /*sync_tree = */ false);
+ auto serve_result = ServeApi::Instance().RetrieveTreeFromCommit(
+ repo_info.hash,
+ repo_info.subdir,
+ /*sync_tree = */ false);
if (std::holds_alternative<std::string>(serve_result)) {
// set the workspace root as absent
JustMRProgress::Instance().TaskTracker().Stop(
@@ -544,10 +544,10 @@ void EnsureCommit(
// otherwise, request (and sync) the whole commit tree, to ensure
// we maintain the id file association
else {
- auto serve_result =
- ServeApi::RetrieveTreeFromCommit(repo_info.hash,
- /*subdir = */ ".",
- /*sync_tree = */ true);
+ auto serve_result = ServeApi::Instance().RetrieveTreeFromCommit(
+ repo_info.hash,
+ /*subdir = */ ".",
+ /*sync_tree = */ true);
if (std::holds_alternative<std::string>(serve_result)) {
auto const& root_tree_id =
std::get<std::string>(serve_result);
diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp
index cccab118..785c675b 100644
--- a/src/other_tools/root_maps/content_git_map.cpp
+++ b/src/other_tools/root_maps/content_git_map.cpp
@@ -73,11 +73,12 @@ void EnsureRootAsAbsent(
// root itself; this is redundant if root is not already cached
if (is_cache_hit) {
auto serve_result =
- ServeApi::RetrieveTreeFromArchive(key.archive.content,
- key.repo_type,
- key.subdir,
- key.pragma_special,
- /*sync_tree=*/false);
+ ServeApi::Instance().RetrieveTreeFromArchive(
+ key.archive.content,
+ key.repo_type,
+ key.subdir,
+ key.pragma_special,
+ /*sync_tree=*/false);
if (std::holds_alternative<std::string>(serve_result)) {
// if serve has set up the tree, it must match what we
// expect
@@ -623,12 +624,13 @@ auto CreateContentGitMap(
// request the resolved subdir tree from the serve endpoint, if
// given
if (serve_api_exists) {
- auto serve_result = ServeApi::RetrieveTreeFromArchive(
- key.archive.content,
- key.repo_type,
- key.subdir,
- key.pragma_special,
- /*sync_tree = */ false);
+ auto serve_result =
+ ServeApi::Instance().RetrieveTreeFromArchive(
+ key.archive.content,
+ key.repo_type,
+ key.subdir,
+ key.pragma_special,
+ /*sync_tree = */ false);
if (std::holds_alternative<std::string>(serve_result)) {
// set the workspace root as absent
JustMRProgress::Instance().TaskTracker().Stop(
diff --git a/src/other_tools/root_maps/distdir_git_map.cpp b/src/other_tools/root_maps/distdir_git_map.cpp
index c1d9bd11..390a5de4 100644
--- a/src/other_tools/root_maps/distdir_git_map.cpp
+++ b/src/other_tools/root_maps/distdir_git_map.cpp
@@ -201,9 +201,10 @@ auto CreateDistdirGitMap(
// try to see if serve endpoint has the
// information to prepare the root itself
auto serve_result =
- ServeApi::RetrieveTreeFromDistdir(
- key.content_list,
- /*sync_tree=*/false);
+ ServeApi::Instance()
+ .RetrieveTreeFromDistdir(
+ key.content_list,
+ /*sync_tree=*/false);
if (std::holds_alternative<std::string>(
serve_result)) {
// if serve has set up the tree, it must
@@ -348,8 +349,9 @@ auto CreateDistdirGitMap(
// try to see if serve endpoint has the information to
// prepare the root itself
auto serve_result =
- ServeApi::RetrieveTreeFromDistdir(key.content_list,
- /*sync_tree=*/false);
+ ServeApi::Instance().RetrieveTreeFromDistdir(
+ key.content_list,
+ /*sync_tree=*/false);
if (std::holds_alternative<std::string>(serve_result)) {
// if serve has set up the tree, it must match what we
// expect
@@ -482,8 +484,9 @@ auto CreateDistdirGitMap(
// a present root, a corresponding remote endpoint is needed
if (serve_api_exists and remote_api) {
auto serve_result =
- ServeApi::RetrieveTreeFromDistdir(key.content_list,
- /*sync_tree=*/true);
+ ServeApi::Instance().RetrieveTreeFromDistdir(
+ key.content_list,
+ /*sync_tree=*/true);
if (std::holds_alternative<std::string>(serve_result)) {
// if serve has set up the tree, it must match what we
// expect
diff --git a/src/other_tools/root_maps/foreign_file_git_map.cpp b/src/other_tools/root_maps/foreign_file_git_map.cpp
index 5e08a18a..3119d84e 100644
--- a/src/other_tools/root_maps/foreign_file_git_map.cpp
+++ b/src/other_tools/root_maps/foreign_file_git_map.cpp
@@ -149,7 +149,7 @@ void HandleAbsentForeignFile(ForeignFileInfo const& key,
/*is_cache_hit=*/false));
return;
}
- auto serve_result = ServeApi::RetrieveTreeFromForeignFile(
+ auto serve_result = ServeApi::Instance().RetrieveTreeFromForeignFile(
key.archive.content, key.name, key.executable);
if (std::holds_alternative<std::string>(serve_result)) {
// if serve has set up the tree, it must match what we
diff --git a/src/other_tools/root_maps/root_utils.cpp b/src/other_tools/root_maps/root_utils.cpp
index f9815d88..f0269b33 100644
--- a/src/other_tools/root_maps/root_utils.cpp
+++ b/src/other_tools/root_maps/root_utils.cpp
@@ -25,7 +25,7 @@
auto CheckServeHasAbsentRoot(std::string const& tree_id,
AsyncMapConsumerLoggerPtr const& logger)
-> std::optional<bool> {
- if (auto has_tree = ServeApi::CheckRootTree(tree_id)) {
+ if (auto has_tree = ServeApi::Instance().CheckRootTree(tree_id)) {
return *has_tree;
}
(*logger)(fmt::format("Checking that the serve endpoint knows tree "
@@ -64,7 +64,7 @@ auto EnsureAbsentRootOnServe(
}
}
// ask serve endpoint to retrieve the uploaded tree
- if (not ServeApi::GetTreeFromRemote(tree_id)) {
+ if (not ServeApi::Instance().GetTreeFromRemote(tree_id)) {
// respond based on no_sync_is_fatal flag
(*logger)(
fmt::format("Serve endpoint failed to sync root tree {}.", tree_id),