diff options
Diffstat (limited to 'zenserver/upstream/upstreamcache.h')
| -rw-r--r-- | zenserver/upstream/upstreamcache.h | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/zenserver/upstream/upstreamcache.h b/zenserver/upstream/upstreamcache.h new file mode 100644 index 000000000..23a542151 --- /dev/null +++ b/zenserver/upstream/upstreamcache.h @@ -0,0 +1,82 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include <zencore/iobuffer.h> +#include <zencore/iohash.h> +#include <zencore/zencore.h> + +#include <memory> + +class ZenCacheStore; + +namespace zen { + +class CidStore; + +struct UpstreamCacheKey +{ + std::string Bucket; + IoHash Hash; +}; + +struct UpstreamPayloadKey +{ + UpstreamCacheKey CacheKey; + IoHash PayloadId; +}; + +struct UpstreamCacheRecord +{ + ZenContentType Type = ZenContentType::kBinary; + UpstreamCacheKey CacheKey; + std::vector<IoHash> PayloadIds; +}; + +struct UpstreamCacheOptions +{ + uint32_t ThreadCount = 4; + bool JupiterEnabled = true; + std::string_view JupiterEndpoint; + std::string_view JupiterDdcNamespace; + std::string_view JupiterBlobStoreNamespace; + std::string_view JupiterOAuthProvider; + std::string_view JupiterOAuthClientId; + std::string_view JupiterOAuthSecret; +}; + +/** + * Manages one or more upstream cache endpoints. + */ +class UpstreamCache +{ +public: + virtual ~UpstreamCache() = default; + + struct GetCacheRecordResult + { + IoBuffer Value; + bool Success = false; + }; + + virtual GetCacheRecordResult GetCacheRecord(UpstreamCacheKey CacheKey, ZenContentType Type) = 0; + + struct GetCachePayloadResult + { + IoBuffer Payload; + bool Success = false; + }; + + virtual GetCachePayloadResult GetCachePayload(UpstreamPayloadKey PayloadKey) = 0; + + struct EnqueueResult + { + bool Success = false; + }; + + virtual EnqueueResult EnqueueUpstream(UpstreamCacheRecord CacheRecord) = 0; +}; + +std::unique_ptr<UpstreamCache> MakeUpstreamCache(const UpstreamCacheOptions& Options, ::ZenCacheStore& CacheStore, CidStore& CidStore); + +} // namespace zen |