diff options
-rw-r--r-- | src/buildtool/serve_api/serve_service/target.cpp | 4 | ||||
-rw-r--r-- | src/buildtool/storage/target_cache.hpp | 18 | ||||
-rw-r--r-- | src/buildtool/storage/target_cache.tpp | 2 | ||||
-rw-r--r-- | src/buildtool/storage/uplinker.cpp | 2 | ||||
-rw-r--r-- | src/buildtool/storage/uplinker.hpp | 4 |
5 files changed, 15 insertions, 15 deletions
diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp index 019a258b..6b46dbea 100644 --- a/src/buildtool/serve_api/serve_service/target.cpp +++ b/src/buildtool/serve_api/serve_service/target.cpp @@ -224,8 +224,8 @@ auto TargetService::ServeTarget( } // get a target cache instance with the correct computed shard - auto const tc = local_context_.storage->TargetCache().WithShard( - execution_backend_dgst->hash()); + auto const tc = + local_context_.storage->TargetCache().WithShard(*description); auto const tc_key = TargetCacheKey{{*target_cache_key_digest, ObjectType::File}}; diff --git a/src/buildtool/storage/target_cache.hpp b/src/buildtool/storage/target_cache.hpp index 08dc498c..d674a9ed 100644 --- a/src/buildtool/storage/target_cache.hpp +++ b/src/buildtool/storage/target_cache.hpp @@ -60,18 +60,16 @@ class TargetCache { : TargetCache(cas, config.target_cache, uplinker, - config.storage_config->backend_description - .HashContent(cas->GetHashFunction()) - .hash()) {} + config.storage_config->backend_description) {} /// \brief Returns a new TargetCache backed by the same CAS, but the /// FileStorage uses the given \p backend_description 's hash. This is /// particularly useful for the just-serve server implementation, since the /// sharding must be performed according to the client's request and not /// following the server configuration. - [[nodiscard]] auto WithShard(std::string backend_description) const + [[nodiscard]] auto WithShard(BackendDescription backend_description) const -> TargetCache { - if (backend_description_id_ == backend_description) { + if (backend_description_ == backend_description) { return *this; } @@ -139,17 +137,19 @@ class TargetCache { /*kSetEpochTime=*/false> file_store_; Uplinker<kDoGlobalUplink> const& uplinker_; - std::string const backend_description_id_; + BackendDescription const backend_description_; explicit TargetCache( gsl::not_null<LocalCAS<kDoGlobalUplink> const*> const& cas, std::filesystem::path const& root, gsl::not_null<Uplinker<kDoGlobalUplink> const*> const& uplinker, - std::string backend_description_id) + BackendDescription backend_description) : cas_{*cas}, - file_store_{root / backend_description_id}, + file_store_{ + root / + backend_description.HashContent(cas->GetHashFunction()).hash()}, uplinker_{*uplinker}, - backend_description_id_{std::move(backend_description_id)} {} + backend_description_{std::move(backend_description)} {} template <bool kIsLocalGeneration = not kDoGlobalUplink> requires(kIsLocalGeneration) diff --git a/src/buildtool/storage/target_cache.tpp b/src/buildtool/storage/target_cache.tpp index f867d181..5a6acb88 100644 --- a/src/buildtool/storage/target_cache.tpp +++ b/src/buildtool/storage/target_cache.tpp @@ -79,7 +79,7 @@ auto TargetCache<kDoGlobalUplink>::Read( if constexpr (kDoGlobalUplink) { // Uplink any existing target cache entry in storage generations std::ignore = - uplinker_.UplinkTargetCacheEntry(key, backend_description_id_); + uplinker_.UplinkTargetCacheEntry(key, backend_description_); } auto const entry = diff --git a/src/buildtool/storage/uplinker.cpp b/src/buildtool/storage/uplinker.cpp index f5a291ae..f9e5c33f 100644 --- a/src/buildtool/storage/uplinker.cpp +++ b/src/buildtool/storage/uplinker.cpp @@ -100,7 +100,7 @@ auto GlobalUplinker::UplinkActionCacheEntry( auto GlobalUplinker::UplinkTargetCacheEntry( TargetCacheKey const& key, - std::string const& backend_description) const noexcept -> bool { + BackendDescription const& backend_description) const noexcept -> bool { // Try to find target-cache entry in all generations. auto const& latest = generations_[Generation::kYoungest].TargetCache().WithShard( diff --git a/src/buildtool/storage/uplinker.hpp b/src/buildtool/storage/uplinker.hpp index 56eaea43..015d23ee 100644 --- a/src/buildtool/storage/uplinker.hpp +++ b/src/buildtool/storage/uplinker.hpp @@ -15,12 +15,12 @@ #ifndef INCLUDED_SRC_BUILDTOOL_STORAGE_UPLINKER_HPP #define INCLUDED_SRC_BUILDTOOL_STORAGE_UPLINKER_HPP -#include <string> #include <type_traits> #include <vector> #include "gsl/gsl" #include "src/buildtool/common/artifact_digest.hpp" +#include "src/buildtool/storage/backend_description.hpp" #include "src/buildtool/storage/config.hpp" template <bool> @@ -77,7 +77,7 @@ class GlobalUplinker final { /// \returns true if cache entry was found and successfully uplinked. [[nodiscard]] auto UplinkTargetCacheEntry( TargetCacheKey const& key, - std::string const& backend_description) const noexcept -> bool; + BackendDescription const& backend_description) const noexcept -> bool; private: StorageConfig const& storage_config_; |