diff options
| author | Per Larsson <[email protected]> | 2021-09-03 15:37:19 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-09-03 15:37:19 +0200 |
| commit | c04fa527593da17c719c4d899ec19caeb6480a94 (patch) | |
| tree | fa65fd7585d55712bad546d76a0fc3518023a905 /zenserver/upstream/upstreamcache.h | |
| parent | oops: Fixed AssertException implementation namespace (diff) | |
| download | zen-c04fa527593da17c719c4d899ec19caeb6480a94.tar.xz zen-c04fa527593da17c719c4d899ec19caeb6480a94.zip | |
Zen upstream support (#7)
Diffstat (limited to 'zenserver/upstream/upstreamcache.h')
| -rw-r--r-- | zenserver/upstream/upstreamcache.h | 64 |
1 files changed, 44 insertions, 20 deletions
diff --git a/zenserver/upstream/upstreamcache.h b/zenserver/upstream/upstreamcache.h index 23a542151..d8359bc2c 100644 --- a/zenserver/upstream/upstreamcache.h +++ b/zenserver/upstream/upstreamcache.h @@ -13,6 +13,7 @@ class ZenCacheStore; namespace zen { class CidStore; +struct CloudCacheClientOptions; struct UpstreamCacheKey { @@ -35,14 +36,41 @@ struct UpstreamCacheRecord 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; + uint32_t ThreadCount = 4; +}; + +struct GetUpstreamCacheResult +{ + IoBuffer Value; + std::string Reason; + bool Success = false; +}; + +struct PutUpstreamCacheResult +{ + std::string Reason; + bool Success; +}; + +/** + * The upstream endpont is responsible for handling upload/downloading of cache records. + */ +class UpstreamEndpoint +{ +public: + virtual ~UpstreamEndpoint() = default; + + virtual bool Initialize() = 0; + + virtual std::string_view DisplayName() const = 0; + + virtual GetUpstreamCacheResult GetCacheRecord(UpstreamCacheKey CacheKey, ZenContentType Type) = 0; + + virtual GetUpstreamCacheResult GetCachePayload(UpstreamPayloadKey PayloadKey) = 0; + + virtual PutUpstreamCacheResult PutCacheRecord(const UpstreamCacheRecord& CacheRecord, + IoBuffer RecordValue, + std::span<IoBuffer const> Payloads) = 0; }; /** @@ -53,21 +81,13 @@ class UpstreamCache public: virtual ~UpstreamCache() = default; - struct GetCacheRecordResult - { - IoBuffer Value; - bool Success = false; - }; + virtual bool Initialize() = 0; - virtual GetCacheRecordResult GetCacheRecord(UpstreamCacheKey CacheKey, ZenContentType Type) = 0; + virtual void AddEndpoint(std::unique_ptr<UpstreamEndpoint> Endpoint) = 0; - struct GetCachePayloadResult - { - IoBuffer Payload; - bool Success = false; - }; + virtual GetUpstreamCacheResult GetCacheRecord(UpstreamCacheKey CacheKey, ZenContentType Type) = 0; - virtual GetCachePayloadResult GetCachePayload(UpstreamPayloadKey PayloadKey) = 0; + virtual GetUpstreamCacheResult GetCachePayload(UpstreamPayloadKey PayloadKey) = 0; struct EnqueueResult { @@ -79,4 +99,8 @@ public: std::unique_ptr<UpstreamCache> MakeUpstreamCache(const UpstreamCacheOptions& Options, ::ZenCacheStore& CacheStore, CidStore& CidStore); +std::unique_ptr<UpstreamEndpoint> MakeJupiterUpstreamEndpoint(const CloudCacheClientOptions& Options); + +std::unique_ptr<UpstreamEndpoint> MakeZenUpstreamEndpoint(std::string_view Url); + } // namespace zen |