From bd85a74a9d15fd676a6677fbd4d5ab4e3dcb0d42 Mon Sep 17 00:00:00 2001 From: mattpetersepic <58296718+mattpetersepic@users.noreply.github.com> Date: Tue, 25 Jan 2022 06:57:47 -0700 Subject: Cachepolicy (#36) * Copy CachePolicy implementation from UE5/Release-5.0. Add backwards compatability for clients and upstreams that are using the old protocol. * Add RefPtr templated move operator and constructor, so that RefPtr A = std::move(RefPtr()) will do a move. * Fix broken CachePolicy tests and add tests for new Save/Load. * Remove TODO comments * CachePolicy Save/Load Fixes from codereview * Fix comment to match code change. * Remove backwards compatibility for CachePolicy change. Convert policy string tokens to PascalCase. Fix tests for new policy text. Change ParseCachePolicy to assert string is non-empty and always succeed. * Fix release build: use ZEN_WITH_TESTS define --- zenserver/upstream/upstreamcache.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'zenserver/upstream/upstreamcache.cpp') diff --git a/zenserver/upstream/upstreamcache.cpp b/zenserver/upstream/upstreamcache.cpp index 3d6641a4f..b0343a61b 100644 --- a/zenserver/upstream/upstreamcache.cpp +++ b/zenserver/upstream/upstreamcache.cpp @@ -378,7 +378,7 @@ namespace detail { if (It == std::end(CacheRecord.PayloadIds)) { - OutReason = fmt::format("payload '{}' MISSING from local cache", PayloadId); + OutReason = fmt::format("value '{}' MISSING from local cache", PayloadId); return false; } @@ -394,7 +394,7 @@ namespace detail { if (!BlobResult.Success) { - OutReason = fmt::format("upload payload '{}' FAILED, reason '{}'", PayloadId, BlobResult.Reason); + OutReason = fmt::format("upload value '{}' FAILED, reason '{}'", PayloadId, BlobResult.Reason); return false; } @@ -473,7 +473,7 @@ namespace detail { Sb << MissingHash.ToHexString() << ","; } - return {.Reason = fmt::format("finalize '{}/{}' FAILED, still needs payload(s) '{}'", + return {.Reason = fmt::format("finalize '{}/{}' FAILED, still needs value(s) '{}'", CacheRecord.Key.Bucket, CacheRecord.Key.Hash, Sb.ToString()), @@ -646,9 +646,8 @@ namespace detail { } BatchRequest.EndArray(); - BatchRequest.BeginObject("Policy"sv); - CacheRecordPolicy::Save(Policy, BatchRequest); - BatchRequest.EndObject(); + BatchRequest.SetName("Policy"sv); + Policy.Save(BatchRequest); } BatchRequest.EndObject(); @@ -726,7 +725,7 @@ namespace detail { CbObjectWriter BatchRequest; BatchRequest << "Method"sv - << "GetCachePayloads"; + << "GetCacheValues"; BatchRequest.BeginObject("Params"sv); { @@ -743,12 +742,11 @@ namespace detail { BatchRequest << "Bucket"sv << Request.Key.Bucket; BatchRequest << "Hash"sv << Request.Key.Hash; BatchRequest.EndObject(); - - BatchRequest.AddObjectId("PayloadId"sv, Request.PayloadId); + BatchRequest.AddObjectId("ValueId"sv, Request.PayloadId); BatchRequest << "ChunkId"sv << Request.ChunkId; BatchRequest << "RawOffset"sv << Request.RawOffset; BatchRequest << "RawSize"sv << Request.RawSize; - BatchRequest << "Policy"sv << static_cast(Request.Policy); + BatchRequest << "Policy"sv << WriteToString<128>(Request.Policy).ToView(); } BatchRequest.EndObject(); } @@ -828,7 +826,7 @@ namespace detail { } else { - return {.Reason = std::string("invalid payload buffer"), .Success = false}; + return {.Reason = std::string("invalid value buffer"), .Success = false}; } } -- cgit v1.2.3