aboutsummaryrefslogtreecommitdiff
path: root/zenserver/upstream/jupiter.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-05-21 16:20:49 +0200
committerStefan Boberg <[email protected]>2021-05-21 16:20:49 +0200
commit8bdf5286eab1b7b2aeff8ce69cfaf0d6bc2f0017 (patch)
tree547be6cf1ce1dd5bc8a88c2ed3a7dcb54e3664e7 /zenserver/upstream/jupiter.cpp
parentAdded Oid::operator bool for "null" checking (diff)
parentMerge branch 'main' into jupiter-structured (diff)
downloadzen-8bdf5286eab1b7b2aeff8ce69cfaf0d6bc2f0017.tar.xz
zen-8bdf5286eab1b7b2aeff8ce69cfaf0d6bc2f0017.zip
Merge branch 'jupiter-structured' of https://github.com/EpicGames/zen into jupiter-structured
Diffstat (limited to 'zenserver/upstream/jupiter.cpp')
-rw-r--r--zenserver/upstream/jupiter.cpp51
1 files changed, 40 insertions, 11 deletions
diff --git a/zenserver/upstream/jupiter.cpp b/zenserver/upstream/jupiter.cpp
index 88a164fbd..363ebcd61 100644
--- a/zenserver/upstream/jupiter.cpp
+++ b/zenserver/upstream/jupiter.cpp
@@ -3,6 +3,7 @@
#include "jupiter.h"
#include <fmt/format.h>
+#include <zencore/compactbinary.h>
#include <zencore/iobuffer.h>
#include <zencore/iohash.h>
#include <zencore/string.h>
@@ -108,26 +109,54 @@ CloudCacheSession::Put(std::string_view BucketId, std::string_view Key, IoBuffer
}
}
-//////////////////////////////////////////////////////////////////////////
-
-IoBuffer
-CloudCacheSession::Get(std::string_view BucketId, const IoHash& Key)
+void
+CloudCacheSession::Put(std::string_view BucketId, std::string_view Key, CbObjectView Data)
{
- StringBuilder<64> KeyString;
- Key.ToHexString(KeyString);
+ ExtendableStringBuilder<256> Uri;
+ Uri << m_CacheClient->ServiceUrl();
+ Uri << "/api/v1/c/ddc/" << m_CacheClient->Namespace() << "/" << BucketId << "/" TESTING_PREFIX << Key;
- return Get(BucketId, KeyString);
+ auto& Session = m_SessionState->Session;
+
+ IoHash Hash = Data.GetHash();
+ MemoryView DataView = Data.GetView();
+
+ std::string Auth;
+ m_CacheClient->AcquireAccessToken(Auth);
+ Session.SetOption(cpr::Url{Uri.c_str()});
+ Session.SetOption(
+ cpr::Header{{"Authorization", Auth}, {"X-Jupiter-IoHash", Hash.ToHexString()}, {"Content-Type", "application/x-ue-cb"}});
+ Session.SetOption(cpr::Body{(const char*)DataView.GetData(), DataView.GetSize()});
+
+ cpr::Response Response = Session.Put();
+
+ if (Response.error)
+ {
+ spdlog::warn("PUT failed: '{}'", Response.error.message);
+ }
}
-void
-CloudCacheSession::Put(std::string_view BucketId, const IoHash& Key, IoBuffer Data, HttpContentType ContentType)
+std::vector<IoHash>
+CloudCacheSession::Filter(std::string_view BucketId, const std::vector<IoHash>& ChunkHashes)
{
- ZEN_UNUSED(ContentType);
+ ExtendableStringBuilder<256> Uri;
+ Uri << m_CacheClient->ServiceUrl();
+ Uri << "/api/v1/s/" << m_CacheClient->Namespace();
+
+ ZEN_UNUSED(BucketId, ChunkHashes);
+ return {};
+}
+
+//////////////////////////////////////////////////////////////////////////
+
+IoBuffer
+CloudCacheSession::Get(std::string_view BucketId, const IoHash& Key)
+{
StringBuilder<64> KeyString;
Key.ToHexString(KeyString);
- return Put(BucketId, KeyString, Data);
+ return Get(BucketId, KeyString);
}
//////////////////////////////////////////////////////////////////////////