diff options
| author | Per Larsson <[email protected]> | 2021-08-31 15:01:46 +0200 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-08-31 15:16:22 +0200 |
| commit | fd3946f2b2b013af01fdf60f67afb655c38c1901 (patch) | |
| tree | eca4abed5d71a157e185699f4e9668a92b756ca8 /zenserver/upstream/upstreamcache.h | |
| parent | Removed unused packages from vcpkg.json (diff) | |
| download | zen-fd3946f2b2b013af01fdf60f67afb655c38c1901.tar.xz zen-fd3946f2b2b013af01fdf60f67afb655c38c1901.zip | |
Asynchronous upstream caching to Jupiter
Co-authored-by: Stefan Boberg <[email protected]>
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 |