aboutsummaryrefslogtreecommitdiff
path: root/zenserver/upstream/jupiter.h
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2021-08-31 15:01:46 +0200
committerPer Larsson <[email protected]>2021-08-31 15:16:22 +0200
commitfd3946f2b2b013af01fdf60f67afb655c38c1901 (patch)
treeeca4abed5d71a157e185699f4e9668a92b756ca8 /zenserver/upstream/jupiter.h
parentRemoved unused packages from vcpkg.json (diff)
downloadzen-fd3946f2b2b013af01fdf60f67afb655c38c1901.tar.xz
zen-fd3946f2b2b013af01fdf60f67afb655c38c1901.zip
Asynchronous upstream caching to Jupiter
Co-authored-by: Stefan Boberg <[email protected]>
Diffstat (limited to 'zenserver/upstream/jupiter.h')
-rw-r--r--zenserver/upstream/jupiter.h38
1 files changed, 28 insertions, 10 deletions
diff --git a/zenserver/upstream/jupiter.h b/zenserver/upstream/jupiter.h
index 2ed458142..61d1bd99c 100644
--- a/zenserver/upstream/jupiter.h
+++ b/zenserver/upstream/jupiter.h
@@ -6,6 +6,8 @@
#include <zencore/refcount.h>
#include <zencore/thread.h>
+#include <spdlog/spdlog.h>
+
#include <atomic>
#include <list>
#include <memory>
@@ -39,6 +41,12 @@ private:
std::atomic<uint32_t> m_Serial;
};
+struct CloudCacheResult
+{
+ IoBuffer Value;
+ bool Success = false;
+};
+
/**
* Context for performing Jupiter operations
*
@@ -52,17 +60,20 @@ public:
CloudCacheSession(CloudCacheClient* OuterClient);
~CloudCacheSession();
- // Key-value cache operations
- IoBuffer Get(std::string_view BucketId, std::string_view Key);
- void Put(std::string_view BucketId, std::string_view Key, IoBuffer Data);
+ CloudCacheResult GetDerivedData(std::string_view BucketId, std::string_view Key);
+ CloudCacheResult GetDerivedData(std::string_view BucketId, const IoHash& Key);
+ CloudCacheResult GetRef(std::string_view BucketId, const IoHash& Key);
+ CloudCacheResult GetCompressedBlob(const IoHash& Key);
- // Structured cache operations
- IoBuffer Get(std::string_view BucketId, const IoHash& Key);
- void Put(std::string_view BucketId, const IoHash& Key, ZenCacheValue Data);
+ CloudCacheResult PutDerivedData(std::string_view BucketId, std::string_view Key, IoBuffer DerivedData);
+ CloudCacheResult PutDerivedData(std::string_view BucketId, const IoHash& Key, IoBuffer DerivedData);
+ CloudCacheResult PutRef(std::string_view BucketId, const IoHash& Key, IoBuffer Ref);
+ CloudCacheResult PutCompressedBlob(const IoHash& Key, IoBuffer Blob);
std::vector<IoHash> Filter(std::string_view BucketId, const std::vector<IoHash>& ChunkHashes);
private:
+ spdlog::logger& m_Log;
RefPtr<CloudCacheClient> m_CacheClient;
detail::CloudCacheSessionState* m_SessionState;
};
@@ -74,28 +85,35 @@ class CloudCacheClient : public RefCounted
{
public:
CloudCacheClient(std::string_view ServiceUrl,
- std::string_view Namespace,
+ std::string_view DdcNamespace,
+ std::string_view BlobStoreNamespace,
std::string_view OAuthProvider,
std::string_view OAuthClientId,
std::string_view OAuthSecret);
~CloudCacheClient();
bool AcquireAccessToken(std::string& AuthorizationHeaderValue);
- std::string_view Namespace() const { return m_Namespace; }
+ std::string_view DdcNamespace() const { return m_DdcNamespace; }
+ std::string_view BlobStoreNamespace() const { return m_BlobStoreNamespace; }
std::string_view DefaultBucket() const { return m_DefaultBucket; }
std::string_view ServiceUrl() const { return m_ServiceUrl; }
+ bool IsValid() const { return m_IsValid; }
+
+ spdlog::logger& Logger() { return m_Log; }
private:
- bool m_IsValid = false;
+ spdlog::logger& m_Log;
std::string m_ServiceUrl;
std::string m_OAuthDomain;
std::string m_OAuthUriPath;
std::string m_OAuthFullUri;
- std::string m_Namespace;
+ std::string m_DdcNamespace;
+ std::string m_BlobStoreNamespace;
std::string m_DefaultBucket;
std::string m_OAuthClientId;
std::string m_OAuthSecret;
CloudCacheAccessToken m_AccessToken;
+ bool m_IsValid = false;
RwLock m_SessionStateLock;
std::list<detail::CloudCacheSessionState*> m_SessionStateCache;