summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/execution_api/execution_service/TARGETS12
-rw-r--r--src/buildtool/execution_api/execution_service/ac_server.hpp7
-rw-r--r--src/buildtool/execution_api/execution_service/bytestream_server.hpp7
-rw-r--r--src/buildtool/execution_api/execution_service/cas_server.hpp7
-rw-r--r--src/buildtool/execution_api/execution_service/execution_server.hpp8
-rw-r--r--src/buildtool/execution_api/execution_service/server_implementation.cpp12
-rw-r--r--src/buildtool/execution_api/execution_service/server_implementation.hpp10
-rw-r--r--src/buildtool/main/main.cpp7
-rw-r--r--src/buildtool/serve_api/serve_service/TARGETS10
-rw-r--r--src/buildtool/serve_api/serve_service/serve_server_implementation.cpp48
-rw-r--r--src/buildtool/serve_api/serve_service/serve_server_implementation.hpp13
-rw-r--r--src/buildtool/serve_api/serve_service/source_tree.hpp8
-rw-r--r--src/buildtool/serve_api/serve_service/target.cpp51
-rw-r--r--src/buildtool/serve_api/serve_service/target.hpp16
14 files changed, 100 insertions, 116 deletions
diff --git a/src/buildtool/execution_api/execution_service/TARGETS b/src/buildtool/execution_api/execution_service/TARGETS
index 7d82602c..270d103d 100644
--- a/src/buildtool/execution_api/execution_service/TARGETS
+++ b/src/buildtool/execution_api/execution_service/TARGETS
@@ -9,6 +9,7 @@
[ "operation_cache"
, ["@", "gsl", "", "gsl"]
, ["src/buildtool/execution_api/common", "common"]
+ , ["src/buildtool/execution_api/local", "context"]
, ["src/buildtool/logging", "logging"]
, ["src/buildtool/common", "bazel_types"]
, ["src/buildtool/storage", "storage"]
@@ -33,6 +34,7 @@
, "stage": ["src", "buildtool", "execution_api", "execution_service"]
, "deps":
[ ["@", "gsl", "", "gsl"]
+ , ["src/buildtool/execution_api/local", "context"]
, ["src/buildtool/logging", "logging"]
, ["src/buildtool/common", "bazel_types"]
, ["src/buildtool/storage", "storage"]
@@ -49,10 +51,11 @@
, "proto": [["@", "bazel_remote_apis", "", "remote_execution_proto"]]
, "stage": ["src", "buildtool", "execution_api", "execution_service"]
, "deps":
- [ ["src/buildtool/logging", "logging"]
+ [ ["@", "gsl", "", "gsl"]
+ , ["src/buildtool/execution_api/local", "context"]
+ , ["src/buildtool/logging", "logging"]
, ["src/buildtool/common", "bazel_types"]
, ["src/buildtool/storage", "storage"]
- , ["@", "gsl", "", "gsl"]
, ["src/buildtool/storage", "config"]
]
, "private-deps":
@@ -71,8 +74,7 @@
, "stage": ["src", "buildtool", "execution_api", "execution_service"]
, "deps":
[ ["src/buildtool/execution_api/common", "api_bundle"]
- , ["src/buildtool/storage", "config"]
- , ["src/buildtool/storage", "storage"]
+ , ["src/buildtool/execution_api/local", "context"]
]
, "private-deps":
[ "execution_server"
@@ -86,7 +88,6 @@
, ["src/buildtool/logging", "logging"]
, ["@", "json", "", "json"]
, ["@", "grpc", "", "grpc++"]
- , ["src/buildtool/execution_api/remote", "config"]
, ["@", "fmt", "", "fmt"]
, ["src/buildtool/compatibility", "compatibility"]
, ["src/buildtool/common/remote", "port"]
@@ -101,6 +102,7 @@
, "stage": ["src", "buildtool", "execution_api", "execution_service"]
, "deps":
[ ["@", "gsl", "", "gsl"]
+ , ["src/buildtool/execution_api/local", "context"]
, ["src/buildtool/logging", "logging"]
, ["src/buildtool/storage", "storage"]
, ["src/buildtool/storage", "config"]
diff --git a/src/buildtool/execution_api/execution_service/ac_server.hpp b/src/buildtool/execution_api/execution_service/ac_server.hpp
index 3072c70a..59b8297f 100644
--- a/src/buildtool/execution_api/execution_service/ac_server.hpp
+++ b/src/buildtool/execution_api/execution_service/ac_server.hpp
@@ -18,6 +18,7 @@
#include "build/bazel/remote/execution/v2/remote_execution.grpc.pb.h"
#include "gsl/gsl"
#include "src/buildtool/common/bazel_types.hpp"
+#include "src/buildtool/execution_api/local/context.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/storage.hpp"
@@ -25,9 +26,9 @@
class ActionCacheServiceImpl final : public bazel_re::ActionCache::Service {
public:
explicit ActionCacheServiceImpl(
- gsl::not_null<StorageConfig const*> const& storage_config,
- gsl::not_null<Storage const*> const& storage) noexcept
- : storage_config_{*storage_config}, storage_{*storage} {}
+ gsl::not_null<LocalContext const*> const& local_context) noexcept
+ : storage_config_{*local_context->storage_config},
+ storage_{*local_context->storage} {}
// Retrieve a cached execution result.
//
diff --git a/src/buildtool/execution_api/execution_service/bytestream_server.hpp b/src/buildtool/execution_api/execution_service/bytestream_server.hpp
index 870aed77..e246da0c 100644
--- a/src/buildtool/execution_api/execution_service/bytestream_server.hpp
+++ b/src/buildtool/execution_api/execution_service/bytestream_server.hpp
@@ -17,6 +17,7 @@
#include "google/bytestream/bytestream.grpc.pb.h"
#include "gsl/gsl"
+#include "src/buildtool/execution_api/local/context.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/storage.hpp"
@@ -24,9 +25,9 @@
class BytestreamServiceImpl : public ::google::bytestream::ByteStream::Service {
public:
explicit BytestreamServiceImpl(
- gsl::not_null<StorageConfig const*> const& storage_config,
- gsl::not_null<Storage const*> const& storage) noexcept
- : storage_config_{*storage_config}, storage_{*storage} {}
+ gsl::not_null<LocalContext const*> const& local_context) noexcept
+ : storage_config_{*local_context->storage_config},
+ storage_{*local_context->storage} {}
// `Read()` is used to retrieve the contents of a resource as a sequence
// of bytes. The bytes are returned in a sequence of responses, and the
diff --git a/src/buildtool/execution_api/execution_service/cas_server.hpp b/src/buildtool/execution_api/execution_service/cas_server.hpp
index 5ad9e799..3c84ade1 100644
--- a/src/buildtool/execution_api/execution_service/cas_server.hpp
+++ b/src/buildtool/execution_api/execution_service/cas_server.hpp
@@ -21,6 +21,7 @@
#include "build/bazel/remote/execution/v2/remote_execution.grpc.pb.h"
#include "gsl/gsl"
#include "src/buildtool/common/bazel_types.hpp"
+#include "src/buildtool/execution_api/local/context.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/storage.hpp"
@@ -29,9 +30,9 @@ class CASServiceImpl final
: public bazel_re::ContentAddressableStorage::Service {
public:
explicit CASServiceImpl(
- gsl::not_null<StorageConfig const*> const& storage_config,
- gsl::not_null<Storage const*> const& storage) noexcept
- : storage_config_{*storage_config}, storage_{*storage} {}
+ gsl::not_null<LocalContext const*> const& local_context) noexcept
+ : storage_config_{*local_context->storage_config},
+ storage_{*local_context->storage} {}
// Determine if blobs are present in the CAS.
//
diff --git a/src/buildtool/execution_api/execution_service/execution_server.hpp b/src/buildtool/execution_api/execution_service/execution_server.hpp
index 7107ed45..e09f028b 100644
--- a/src/buildtool/execution_api/execution_service/execution_server.hpp
+++ b/src/buildtool/execution_api/execution_service/execution_server.hpp
@@ -25,6 +25,7 @@
#include "src/buildtool/common/bazel_types.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/execution_api/execution_service/operation_cache.hpp"
+#include "src/buildtool/execution_api/local/context.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/storage.hpp"
@@ -32,12 +33,11 @@
class ExecutionServiceImpl final : public bazel_re::Execution::Service {
public:
explicit ExecutionServiceImpl(
- gsl::not_null<StorageConfig const*> const& storage_config,
- gsl::not_null<Storage const*> const& storage,
+ gsl::not_null<LocalContext const*> const& local_context,
gsl::not_null<IExecutionApi const*> const& local_api,
std::optional<std::uint8_t> op_exponent) noexcept
- : storage_config_{*storage_config},
- storage_{*storage},
+ : storage_config_{*local_context->storage_config},
+ storage_{*local_context->storage},
api_{*local_api} {
if (op_exponent) {
op_cache_.SetExponent(*op_exponent);
diff --git a/src/buildtool/execution_api/execution_service/server_implementation.cpp b/src/buildtool/execution_api/execution_service/server_implementation.cpp
index 73734840..11be6309 100644
--- a/src/buildtool/execution_api/execution_service/server_implementation.cpp
+++ b/src/buildtool/execution_api/execution_service/server_implementation.cpp
@@ -81,15 +81,13 @@ auto ServerImpl::Create(std::optional<std::string> interface,
return std::move(server);
}
-auto ServerImpl::Run(StorageConfig const& storage_config,
- Storage const& storage,
+auto ServerImpl::Run(gsl::not_null<LocalContext const*> const& local_context,
ApiBundle const& apis,
std::optional<std::uint8_t> op_exponent) -> bool {
- ExecutionServiceImpl es{
- &storage_config, &storage, &*apis.local, op_exponent};
- ActionCacheServiceImpl ac{&storage_config, &storage};
- CASServiceImpl cas{&storage_config, &storage};
- BytestreamServiceImpl b{&storage_config, &storage};
+ ExecutionServiceImpl es{local_context, &*apis.local, op_exponent};
+ ActionCacheServiceImpl ac{local_context};
+ CASServiceImpl cas{local_context};
+ BytestreamServiceImpl b{local_context};
CapabilitiesServiceImpl cap{};
OperarationsServiceImpl op{&es.GetOpCache()};
diff --git a/src/buildtool/execution_api/execution_service/server_implementation.hpp b/src/buildtool/execution_api/execution_service/server_implementation.hpp
index d9e16dad..4df8375f 100644
--- a/src/buildtool/execution_api/execution_service/server_implementation.hpp
+++ b/src/buildtool/execution_api/execution_service/server_implementation.hpp
@@ -20,9 +20,9 @@
#include <optional>
#include <string>
+#include "gsl/gsl"
#include "src/buildtool/execution_api/common/api_bundle.hpp"
-#include "src/buildtool/storage/config.hpp"
-#include "src/buildtool/storage/storage.hpp"
+#include "src/buildtool/execution_api/local/context.hpp"
class ServerImpl final {
public:
@@ -42,13 +42,11 @@ class ServerImpl final {
auto operator=(ServerImpl&&) noexcept -> ServerImpl& = default;
/// \brief Start the execution service.
- /// \param storage_config StorageConfig to be used.
- /// \param storage Storage to be used.
+ /// \param local_context The LocalContext to be used.
/// \param apis Apis to be used, only local api is actually
/// needed.
/// \param op_exponent Log2 threshold for operation cache.
- auto Run(StorageConfig const& storage_config,
- Storage const& storage,
+ auto Run(gsl::not_null<LocalContext const*> const& local_context,
ApiBundle const& apis,
std::optional<std::uint8_t> op_exponent) -> bool;
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 774f1356..1676cbb4 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -822,8 +822,7 @@ auto main(int argc, char* argv[]) -> int {
&retry_config,
&remote_exec_config};
- return execution_server->Run(*storage_config,
- storage,
+ return execution_server->Run(&local_context,
exec_apis,
arguments.service.op_exponent)
? kExitSuccess
@@ -894,9 +893,7 @@ auto main(int argc, char* argv[]) -> int {
with_execute ? arguments.service.op_exponent : std::nullopt;
return serve_server->Run(*serve_config,
- *storage_config,
- storage,
- *local_exec_config,
+ &local_context,
serve,
serve_apis,
op_exponent,
diff --git a/src/buildtool/serve_api/serve_service/TARGETS b/src/buildtool/serve_api/serve_service/TARGETS
index 7dbcc01d..18d04bc2 100644
--- a/src/buildtool/serve_api/serve_service/TARGETS
+++ b/src/buildtool/serve_api/serve_service/TARGETS
@@ -19,6 +19,7 @@
, ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/execution_api/remote", "config"]
, ["src/buildtool/execution_api/common", "api_bundle"]
+ , ["src/buildtool/execution_api/local", "context"]
, ["src/buildtool/file_system", "git_types"]
, ["src/buildtool/file_system/symlinks_map", "pragma_special"]
, ["src/buildtool/file_system/symlinks_map", "resolve_symlinks_map"]
@@ -54,9 +55,7 @@
, ["src/buildtool/serve_api/remote", "serve_api"]
, ["src/buildtool/execution_api/common", "api_bundle"]
, ["src/buildtool/execution_api/execution_service", "operation_cache"]
- , ["src/buildtool/execution_api/local", "config"]
- , ["src/buildtool/storage", "config"]
- , ["src/buildtool/storage", "storage"]
+ , ["src/buildtool/execution_api/local", "context"]
]
, "stage": ["src", "buildtool", "serve_api", "serve_service"]
, "private-deps":
@@ -89,11 +88,9 @@
, ["src/buildtool/common/remote", "remote_common"]
, ["src/buildtool/execution_api/common", "api_bundle"]
, ["src/buildtool/execution_api/common", "common"]
- , ["src/buildtool/execution_api/local", "config"]
+ , ["src/buildtool/execution_api/local", "context"]
, ["src/buildtool/serve_api/remote", "config"]
, ["src/utils/cpp", "expected"]
- , ["src/buildtool/storage", "config"]
- , ["src/buildtool/storage", "storage"]
]
, "stage": ["src", "buildtool", "serve_api", "serve_service"]
, "private-deps":
@@ -110,7 +107,6 @@
, ["src/buildtool/common/remote", "retry_config"]
, ["src/buildtool/execution_api/local", "context"]
, ["src/buildtool/execution_api/remote", "config"]
- , ["src/buildtool/execution_api/local", "context"]
, ["src/buildtool/file_system", "file_system_manager"]
, ["src/buildtool/graph_traverser", "graph_traverser"]
, ["src/buildtool/logging", "log_level"]
diff --git a/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp b/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp
index 75d3682d..fac31fbe 100644
--- a/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp
+++ b/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp
@@ -87,35 +87,33 @@ auto ServeServerImpl::Create(std::optional<std::string> interface,
return std::move(server);
}
-auto ServeServerImpl::Run(RemoteServeConfig const& serve_config,
- StorageConfig const& storage_config,
- Storage const& storage,
- LocalExecutionConfig const& local_exec_config,
- std::optional<ServeApi> const& serve,
- ApiBundle const& apis,
- std::optional<std::uint8_t> op_exponent,
- bool with_execute) -> bool {
+auto ServeServerImpl::Run(
+ RemoteServeConfig const& serve_config,
+ gsl::not_null<LocalContext const*> const& local_context,
+ std::optional<ServeApi> const& serve,
+ ApiBundle const& apis,
+ std::optional<std::uint8_t> op_exponent,
+ bool with_execute) -> bool {
// make sure the git root directory is properly initialized
- if (not FileSystemManager::CreateDirectory(storage_config.GitRoot())) {
+ if (not FileSystemManager::CreateDirectory(
+ local_context->storage_config->GitRoot())) {
Logger::Log(LogLevel::Error,
"Could not create directory {}. Aborting",
- storage_config.GitRoot().string());
+ local_context->storage_config->GitRoot().string());
return false;
}
- if (not GitRepo::InitAndOpen(storage_config.GitRoot(), true)) {
- Logger::Log(LogLevel::Error,
- fmt::format("could not initialize bare git repository {}",
- storage_config.GitRoot().string()));
+ if (not GitRepo::InitAndOpen(local_context->storage_config->GitRoot(),
+ true)) {
+ Logger::Log(
+ LogLevel::Error,
+ fmt::format("could not initialize bare git repository {}",
+ local_context->storage_config->GitRoot().string()));
return false;
}
- SourceTreeService sts{&serve_config, &storage_config, &storage, &apis};
- TargetService ts{&serve_config,
- &storage_config,
- &storage,
- &local_exec_config,
- &apis,
- serve ? &*serve : nullptr};
+ SourceTreeService sts{&serve_config, local_context, &apis};
+ TargetService ts{
+ &serve_config, local_context, &apis, serve ? &*serve : nullptr};
ConfigurationService cs{&apis.remote_config};
grpc::ServerBuilder builder;
@@ -127,10 +125,10 @@ auto ServeServerImpl::Run(RemoteServeConfig const& serve_config,
// the user has not given any remote-execution endpoint
// so we start a "just-execute instance" on the same process
[[maybe_unused]] ExecutionServiceImpl es{
- &storage_config, &storage, &*apis.local, op_exponent};
- [[maybe_unused]] ActionCacheServiceImpl ac{&storage_config, &storage};
- [[maybe_unused]] CASServiceImpl cas{&storage_config, &storage};
- [[maybe_unused]] BytestreamServiceImpl b{&storage_config, &storage};
+ local_context, &*apis.local, op_exponent};
+ [[maybe_unused]] ActionCacheServiceImpl ac{local_context};
+ [[maybe_unused]] CASServiceImpl cas{local_context};
+ [[maybe_unused]] BytestreamServiceImpl b{local_context};
[[maybe_unused]] CapabilitiesServiceImpl cap{};
[[maybe_unused]] OperarationsServiceImpl op{&es.GetOpCache()};
if (with_execute) {
diff --git a/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp b/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp
index d3e470fd..4f12ea68 100644
--- a/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp
+++ b/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp
@@ -19,13 +19,12 @@
#include <optional>
#include <string>
+#include "gsl/gsl"
#include "src/buildtool/execution_api/common/api_bundle.hpp"
-#include "src/buildtool/execution_api/local/config.hpp"
+#include "src/buildtool/execution_api/local/context.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/serve_api/remote/config.hpp"
#include "src/buildtool/serve_api/remote/serve_api.hpp"
-#include "src/buildtool/storage/config.hpp"
-#include "src/buildtool/storage/storage.hpp"
class ServeServerImpl final {
public:
@@ -46,16 +45,12 @@ class ServeServerImpl final {
/// \brief Start the serve service.
/// \param serve_config RemoteServeConfig to be used.
- /// \param storage_config StorageConfig to be used.
- /// \param storage Storage to be used.
- /// \param local_exec_config LocalExecutionConfig to be used.
+ /// \param local_context Aggregate of storage and local configs to use.
/// \param serve ServeApi to be used.
/// \param with_execute Flag specifying if just serve should act also as
/// just execute (i.e., start remote execution services with same interface)
auto Run(RemoteServeConfig const& serve_config,
- StorageConfig const& storage_config,
- Storage const& storage,
- LocalExecutionConfig const& local_exec_config,
+ gsl::not_null<LocalContext const*> const& local_context,
std::optional<ServeApi> const& serve,
ApiBundle const& apis,
std::optional<std::uint8_t> op_exponent,
diff --git a/src/buildtool/serve_api/serve_service/source_tree.hpp b/src/buildtool/serve_api/serve_service/source_tree.hpp
index 2f6d649c..288e7da8 100644
--- a/src/buildtool/serve_api/serve_service/source_tree.hpp
+++ b/src/buildtool/serve_api/serve_service/source_tree.hpp
@@ -29,6 +29,7 @@
#include "src/buildtool/common/remote/remote_common.hpp"
#include "src/buildtool/execution_api/common/api_bundle.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
+#include "src/buildtool/execution_api/local/context.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
#include "src/buildtool/file_system/git_types.hpp"
#include "src/buildtool/file_system/symlinks_map/pragma_special.hpp"
@@ -61,12 +62,11 @@ class SourceTreeService final
explicit SourceTreeService(
gsl::not_null<RemoteServeConfig const*> const& serve_config,
- gsl::not_null<StorageConfig const*> const& storage_config,
- gsl::not_null<Storage const*> const& storage,
+ gsl::not_null<LocalContext const*> const& local_context,
gsl::not_null<ApiBundle const*> const& apis) noexcept
: serve_config_{*serve_config},
- storage_{*storage},
- storage_config_{*storage_config},
+ storage_{*local_context->storage},
+ storage_config_{*local_context->storage_config},
apis_{*apis} {}
// Retrieve the Git-subtree identifier from a given Git commit.
diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp
index 1d27baf1..6ab95b8a 100644
--- a/src/buildtool/serve_api/serve_service/target.cpp
+++ b/src/buildtool/serve_api/serve_service/target.cpp
@@ -28,7 +28,6 @@
#include "src/buildtool/common/remote/retry_config.hpp"
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/common/statistics.hpp"
-#include "src/buildtool/execution_api/local/context.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/file_system/object_type.hpp"
@@ -95,7 +94,7 @@ auto TargetService::HandleFailureLog(
logfile.string());
});
// ...but try to give the client the proper log
- auto const& cas = storage_.CAS();
+ auto const& cas = local_context_.storage->CAS();
auto digest = cas.StoreBlob(logfile, /*is_executable=*/false);
if (not digest) {
auto msg = fmt::format("Failed to store log of failed {} to local CAS",
@@ -133,13 +132,14 @@ auto TargetService::ServeTarget(
ArtifactDigest{request->target_cache_key_id()};
// acquire locks
- auto repo_lock = RepositoryGarbageCollector::SharedLock(storage_config_);
+ auto repo_lock =
+ RepositoryGarbageCollector::SharedLock(*local_context_.storage_config);
if (!repo_lock) {
auto msg = std::string("Could not acquire repo gc SharedLock");
logger_->Emit(LogLevel::Error, msg);
return ::grpc::Status{::grpc::StatusCode::INTERNAL, msg};
}
- auto lock = GarbageCollector::SharedLock(storage_config_);
+ auto lock = GarbageCollector::SharedLock(*local_context_.storage_config);
if (!lock) {
auto msg = std::string("Could not acquire CAS gc SharedLock");
logger_->Emit(LogLevel::Error, msg);
@@ -183,7 +183,8 @@ auto TargetService::ServeTarget(
}
// add backend description to CAS
- auto execution_backend_dgst = storage_.CAS().StoreBlob(*description);
+ auto execution_backend_dgst =
+ local_context_.storage->CAS().StoreBlob(*description);
if (not execution_backend_dgst) {
std::string err{
"Failed to store execution backend description in local CAS"};
@@ -196,7 +197,7 @@ auto TargetService::ServeTarget(
address
? std::make_optional(ArtifactDigest(*execution_backend_dgst).hash())
: std::nullopt;
- auto const& tc = storage_.TargetCache().WithShard(shard);
+ auto const& tc = local_context_.storage->TargetCache().WithShard(shard);
auto const& tc_key =
TargetCacheKey{{target_cache_key_digest, ObjectType::File}};
@@ -320,8 +321,8 @@ auto TargetService::ServeTarget(
logger_->Emit(LogLevel::Error, "{}", msg);
return ::grpc::Status{::grpc::StatusCode::FAILED_PRECONDITION, msg};
}
- auto repo_config_path =
- storage_.CAS().BlobPath(repo_key_dgst, /*is_executable=*/false);
+ auto repo_config_path = local_context_.storage->CAS().BlobPath(
+ repo_key_dgst, /*is_executable=*/false);
if (not repo_config_path) {
// This should not fail unless something went really bad...
auto msg = fmt::format(
@@ -335,7 +336,7 @@ auto TargetService::ServeTarget(
RepositoryConfig repository_config{};
std::string const main_repo{"0"}; // known predefined main repository name
if (auto msg = DetermineRoots(serve_config_,
- storage_config_,
+ *local_context_.storage_config,
main_repo,
*repo_config_path,
&repository_config,
@@ -420,7 +421,8 @@ auto TargetService::ServeTarget(
Progress progress{};
// setup logging for analysis and build; write into a temporary file
- auto tmp_dir = storage_config_.CreateTypedTmpDir("serve-target");
+ auto tmp_dir =
+ local_context_.storage_config->CreateTypedTmpDir("serve-target");
if (!tmp_dir) {
auto msg = std::string("Could not create TmpDir");
logger_->Emit(LogLevel::Error, msg);
@@ -430,7 +432,7 @@ auto TargetService::ServeTarget(
Logger logger{"serve-target", {LogSinkFile::CreateFactory(tmp_log)}};
AnalyseContext analyse_ctx{.repo_config = &repository_config,
- .storage = &storage_,
+ .storage = local_context_.storage,
.statistics = &stats,
.progress = &progress,
.serve = serve_};
@@ -484,10 +486,7 @@ auto TargetService::ServeTarget(
// Use a new ApiBundle that knows about local repository config for
// traversing.
- LocalContext const local_context{.exec_config = &local_exec_config_,
- .storage_config = &storage_config_,
- .storage = &storage_};
- ApiBundle const local_apis{&local_context,
+ ApiBundle const local_apis{&local_context_,
&repository_config,
&apis_.auth,
&apis_.retry_config,
@@ -584,8 +583,10 @@ auto TargetService::ServeTargetVariables(
std::optional<std::string> target_file_content{std::nullopt};
bool tree_found{false};
// try in local build root Git cache
- if (auto res = GetBlobContent(
- storage_config_.GitRoot(), root_tree, target_file, logger_)) {
+ if (auto res = GetBlobContent(local_context_.storage_config->GitRoot(),
+ root_tree,
+ target_file,
+ logger_)) {
tree_found = true;
if (res->first) {
if (not res->second) {
@@ -738,7 +739,8 @@ auto TargetService::ServeTargetDescription(
std::optional<std::string> target_file_content{std::nullopt};
bool tree_found{false};
// Get repository lock before inspecting the root git cache
- auto repo_lock = RepositoryGarbageCollector::SharedLock(storage_config_);
+ auto repo_lock =
+ RepositoryGarbageCollector::SharedLock(*local_context_.storage_config);
if (!repo_lock) {
auto msg = std::string("Could not acquire repo gc SharedLock");
logger_->Emit(LogLevel::Error, msg);
@@ -746,8 +748,10 @@ auto TargetService::ServeTargetDescription(
}
// try in local build root Git cache
- if (auto res = GetBlobContent(
- storage_config_.GitRoot(), root_tree, target_file, logger_)) {
+ if (auto res = GetBlobContent(local_context_.storage_config->GitRoot(),
+ root_tree,
+ target_file,
+ logger_)) {
tree_found = true;
if (res->first) {
if (not res->second) {
@@ -876,7 +880,7 @@ auto TargetService::ServeTargetDescription(
}
// acquire lock for CAS
- auto lock = GarbageCollector::SharedLock(storage_config_);
+ auto lock = GarbageCollector::SharedLock(*local_context_.storage_config);
if (!lock) {
auto error_msg = fmt::format("Could not acquire gc SharedLock");
logger_->Emit(LogLevel::Error, error_msg);
@@ -897,8 +901,9 @@ auto TargetService::ServeTargetDescription(
logger_->Emit(LogLevel::Error, err);
return ::grpc::Status{::grpc::StatusCode::INTERNAL, err};
}
- if (auto dgst = storage_.CAS().StoreBlob(description_str,
- /*is_executable=*/false)) {
+ if (auto dgst =
+ local_context_.storage->CAS().StoreBlob(description_str,
+ /*is_executable=*/false)) {
auto const& artifact_dgst = ArtifactDigest{*dgst};
if (not apis_.local->RetrieveToCas(
{Artifact::ObjectInfo{.digest = artifact_dgst,
diff --git a/src/buildtool/serve_api/serve_service/target.hpp b/src/buildtool/serve_api/serve_service/target.hpp
index aaf9bb39..88e5a205 100644
--- a/src/buildtool/serve_api/serve_service/target.hpp
+++ b/src/buildtool/serve_api/serve_service/target.hpp
@@ -30,12 +30,10 @@
#include "src/buildtool/common/remote/remote_common.hpp"
#include "src/buildtool/execution_api/common/api_bundle.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
-#include "src/buildtool/execution_api/local/config.hpp"
+#include "src/buildtool/execution_api/local/context.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/serve_api/remote/config.hpp"
#include "src/buildtool/serve_api/remote/serve_api.hpp"
-#include "src/buildtool/storage/config.hpp"
-#include "src/buildtool/storage/storage.hpp"
#include "src/utils/cpp/expected.hpp"
// The target-level cache service.
@@ -43,15 +41,11 @@ class TargetService final : public justbuild::just_serve::Target::Service {
public:
explicit TargetService(
gsl::not_null<RemoteServeConfig const*> const& serve_config,
- gsl::not_null<StorageConfig const*> const& storage_config,
- gsl::not_null<Storage const*> const& storage,
- gsl::not_null<LocalExecutionConfig const*> const& local_exec_config,
+ gsl::not_null<LocalContext const*> const& local_context,
gsl::not_null<ApiBundle const*> const& apis,
ServeApi const* serve = nullptr) noexcept
: serve_config_{*serve_config},
- storage_config_{*storage_config},
- storage_{*storage},
- local_exec_config_{*local_exec_config},
+ local_context_{*local_context},
apis_{*apis},
serve_{serve} {}
@@ -132,9 +126,7 @@ class TargetService final : public justbuild::just_serve::Target::Service {
private:
RemoteServeConfig const& serve_config_;
- StorageConfig const& storage_config_;
- Storage const& storage_;
- LocalExecutionConfig const& local_exec_config_;
+ LocalContext const& local_context_;
ApiBundle const& apis_;
ServeApi const* const serve_ = nullptr;
std::shared_ptr<Logger> logger_{std::make_shared<Logger>("target-service")};