summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/main/main.cpp5
-rw-r--r--src/buildtool/serve_api/remote/TARGETS1
-rw-r--r--src/buildtool/serve_api/remote/serve_api.hpp12
-rw-r--r--src/buildtool/serve_api/remote/target_client.cpp18
-rw-r--r--src/buildtool/serve_api/remote/target_client.hpp10
-rw-r--r--src/other_tools/just_mr/fetch.cpp2
-rw-r--r--src/other_tools/just_mr/setup.cpp2
7 files changed, 27 insertions, 23 deletions
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 1043de94..6f9c68ad 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -841,7 +841,7 @@ auto main(int argc, char* argv[]) -> int {
if (serve_server) {
ApiBundle const serve_apis{
std::nullopt, RemoteExecutionConfig::RemoteAddress()};
- auto serve = ServeApi::Create(*serve_config);
+ auto serve = ServeApi::Create(*serve_config, &serve_apis);
bool with_execute = not RemoteExecutionConfig::RemoteAddress();
return serve_server->Run(
*serve_config, serve, serve_apis, with_execute)
@@ -928,7 +928,8 @@ auto main(int argc, char* argv[]) -> int {
DetermineRoots(&repo_config, arguments.common, arguments.analysis);
#ifndef BOOTSTRAP_BUILD_TOOL
- std::optional<ServeApi> serve = ServeApi::Create(*serve_config);
+ std::optional<ServeApi> serve =
+ ServeApi::Create(*serve_config, &main_apis);
#else
std::optional<ServeApi> serve;
#endif // BOOTSTRAP_BUILD_TOOL
diff --git a/src/buildtool/serve_api/remote/TARGETS b/src/buildtool/serve_api/remote/TARGETS
index 6443e699..efb923f0 100644
--- a/src/buildtool/serve_api/remote/TARGETS
+++ b/src/buildtool/serve_api/remote/TARGETS
@@ -36,6 +36,7 @@
, ["src/buildtool/common/remote", "port"]
, ["src/buildtool/common/remote", "remote_common"]
, ["src/buildtool/file_system/symlinks_map", "pragma_special"]
+ , ["src/buildtool/execution_api/common", "api_bundle"]
, "source_tree_client"
, "target_client"
, "configuration_client"
diff --git a/src/buildtool/serve_api/remote/serve_api.hpp b/src/buildtool/serve_api/remote/serve_api.hpp
index 89e287a4..9175857b 100644
--- a/src/buildtool/serve_api/remote/serve_api.hpp
+++ b/src/buildtool/serve_api/remote/serve_api.hpp
@@ -29,6 +29,7 @@ class ServeApi final {};
#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/common/remote/port.hpp"
#include "src/buildtool/common/remote/remote_common.hpp"
+#include "src/buildtool/execution_api/common/api_bundle.hpp"
#include "src/buildtool/file_system/symlinks_map/pragma_special.hpp"
#include "src/buildtool/serve_api/remote/config.hpp"
#include "src/buildtool/serve_api/remote/configuration_client.hpp"
@@ -37,8 +38,9 @@ class ServeApi final {};
class ServeApi final {
public:
- explicit ServeApi(ServerAddress const& address) noexcept
- : stc_{address}, tc_{address}, cc_{address} {}
+ explicit ServeApi(ServerAddress const& address,
+ gsl::not_null<ApiBundle const*> const& apis) noexcept
+ : stc_{address}, tc_{address, apis}, cc_{address} {}
~ServeApi() noexcept = default;
ServeApi(ServeApi const&) = delete;
@@ -47,10 +49,12 @@ class ServeApi final {
auto operator=(ServeApi&&) -> ServeApi& = delete;
[[nodiscard]] static auto Create(
- RemoteServeConfig const& serve_config) noexcept
+ RemoteServeConfig const& serve_config,
+ gsl::not_null<ApiBundle const*> const& apis) noexcept
-> std::optional<ServeApi> {
if (serve_config.remote_address) {
- return std::make_optional<ServeApi>(*serve_config.remote_address);
+ return std::make_optional<ServeApi>(*serve_config.remote_address,
+ apis);
}
return std::nullopt;
}
diff --git a/src/buildtool/serve_api/remote/target_client.cpp b/src/buildtool/serve_api/remote/target_client.cpp
index 917f1133..d0e6796e 100644
--- a/src/buildtool/serve_api/remote/target_client.cpp
+++ b/src/buildtool/serve_api/remote/target_client.cpp
@@ -25,7 +25,9 @@
#include "src/buildtool/common/remote/client_common.hpp"
#include "src/buildtool/logging/log_level.hpp"
-TargetClient::TargetClient(ServerAddress const& address) noexcept {
+TargetClient::TargetClient(ServerAddress const& address,
+ gsl::not_null<ApiBundle const*> const& apis) noexcept
+ : apis_{*apis} {
stub_ = justbuild::just_serve::Target::NewStub(
CreateChannelWithCredentials(address.host, address.port));
}
@@ -34,17 +36,17 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key,
const std::string& repo_key) const noexcept
-> std::optional<serve_target_result_t> {
// make sure the blob containing the key is in the remote cas
- if (!local_api_->RetrieveToCas({key.Id()}, &*remote_api_)) {
+ if (!apis_.local->RetrieveToCas({key.Id()}, &*apis_.remote)) {
return serve_target_result_t{
std::in_place_index<1>,
fmt::format("Failed to retrieve to remote cas ObjectInfo {}",
key.Id().ToString())};
}
// make sure the repository configuration blob is in the remote cas
- if (!local_api_->RetrieveToCas(
+ if (!apis_.local->RetrieveToCas(
{Artifact::ObjectInfo{.digest = ArtifactDigest{repo_key, 0, false},
.type = ObjectType::File}},
- &*remote_api_)) {
+ &*apis_.remote)) {
return serve_target_result_t{
std::in_place_index<1>,
fmt::format("Failed to retrieve to remote cas blob {}", repo_key)};
@@ -90,7 +92,7 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key,
}
auto const& dispatch_info = Artifact::ObjectInfo{
.digest = ArtifactDigest{*dispatch_dgst}, .type = ObjectType::File};
- if (!local_api_->RetrieveToCas({dispatch_info}, &*remote_api_)) {
+ if (!apis_.local->RetrieveToCas({dispatch_info}, &*apis_.remote)) {
return serve_target_result_t{
std::in_place_index<1>,
fmt::format("Failed to upload blob {} to remote cas",
@@ -122,8 +124,8 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key,
ArtifactDigest{response.target_value()};
auto const& obj_info = Artifact::ObjectInfo{
.digest = target_value_dgst, .type = ObjectType::File};
- if (!local_api_->IsAvailable(target_value_dgst)) {
- if (!remote_api_->RetrieveToCas({obj_info}, &*local_api_)) {
+ if (!apis_.local->IsAvailable(target_value_dgst)) {
+ if (!apis_.remote->RetrieveToCas({obj_info}, &*apis_.local)) {
return serve_target_result_t{
std::in_place_index<1>,
fmt::format(
@@ -132,7 +134,7 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key,
}
}
auto const& target_value_str =
- local_api_->RetrieveToMemory(obj_info);
+ apis_.local->RetrieveToMemory(obj_info);
if (!target_value_str) {
return serve_target_result_t{
std::in_place_index<1>,
diff --git a/src/buildtool/serve_api/remote/target_client.hpp b/src/buildtool/serve_api/remote/target_client.hpp
index bc3aa382..35bb2d29 100644
--- a/src/buildtool/serve_api/remote/target_client.hpp
+++ b/src/buildtool/serve_api/remote/target_client.hpp
@@ -52,7 +52,8 @@ using serve_target_result_t =
/// src/buildtool/serve_api/serve_service/just_serve.proto
class TargetClient {
public:
- explicit TargetClient(ServerAddress const& address) noexcept;
+ explicit TargetClient(ServerAddress const& address,
+ gsl::not_null<ApiBundle const*> const& apis) noexcept;
/// \brief Retrieve the pair of TargetCacheEntry and ObjectInfo associated
/// to the given key.
@@ -86,14 +87,9 @@ class TargetClient {
const noexcept -> std::optional<ArtifactDigest>;
private:
+ ApiBundle const& apis_;
std::unique_ptr<justbuild::just_serve::Target::Stub> stub_;
Logger logger_{"RemoteTargetClient"};
- gsl::not_null<IExecutionApi::Ptr> const remote_api_{
- CreateExecutionApi(RemoteExecutionConfig::RemoteAddress(),
- std::nullopt,
- "remote-execution")};
- gsl::not_null<IExecutionApi::Ptr> const local_api_{
- CreateExecutionApi(std::nullopt)};
};
#endif // INCLUDED_SRC_BUILDTOOL_SERVE_API_TARGET_CLIENT_HPP
diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp
index 4b90dd61..47c107f3 100644
--- a/src/other_tools/just_mr/fetch.cpp
+++ b/src/other_tools/just_mr/fetch.cpp
@@ -408,7 +408,7 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
return kExitConfigError;
}
- auto serve = ServeApi::Create(*serve_config);
+ auto serve = ServeApi::Create(*serve_config, &apis);
// check configuration of the serve endpoint provided
if (serve) {
// if we have a remote endpoint explicitly given by the user, it must
diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp
index 0900c4fa..8bcefead 100644
--- a/src/other_tools/just_mr/setup.cpp
+++ b/src/other_tools/just_mr/setup.cpp
@@ -127,7 +127,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
return std::nullopt;
}
- auto serve = ServeApi::Create(*serve_config);
+ auto serve = ServeApi::Create(*serve_config, &apis);
// check configuration of the serve endpoint provided
if (serve) {