diff options
| author | Stefan Boberg <[email protected]> | 2021-05-25 09:54:09 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-05-25 09:54:09 +0200 |
| commit | 882e93e4786f9e67e0edf6c276b16bb40848bae9 (patch) | |
| tree | c5d4c45679c676c6aeb804c7601f43340b78ea0b /zenserver/upstream/jupiter.cpp | |
| parent | Updated structured cache description (diff) | |
| parent | Compile out all rocksdb code for a smaller binary (diff) | |
| download | zen-882e93e4786f9e67e0edf6c276b16bb40848bae9.tar.xz zen-882e93e4786f9e67e0edf6c276b16bb40848bae9.zip | |
Merged from origin/main
Diffstat (limited to 'zenserver/upstream/jupiter.cpp')
| -rw-r--r-- | zenserver/upstream/jupiter.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/zenserver/upstream/jupiter.cpp b/zenserver/upstream/jupiter.cpp index 363ebcd61..977bcc712 100644 --- a/zenserver/upstream/jupiter.cpp +++ b/zenserver/upstream/jupiter.cpp @@ -2,6 +2,8 @@ #include "jupiter.h" +#include "cache/structuredcachestore.h" + #include <fmt/format.h> #include <zencore/compactbinary.h> #include <zencore/iobuffer.h> @@ -110,23 +112,38 @@ CloudCacheSession::Put(std::string_view BucketId, std::string_view Key, IoBuffer } void -CloudCacheSession::Put(std::string_view BucketId, std::string_view Key, CbObjectView Data) +CloudCacheSession::Put(std::string_view BucketId, const IoHash& Key, ZenCacheValue Data) { ExtendableStringBuilder<256> Uri; Uri << m_CacheClient->ServiceUrl(); - Uri << "/api/v1/c/ddc/" << m_CacheClient->Namespace() << "/" << BucketId << "/" TESTING_PREFIX << Key; + Uri << "/api/v1/c/ddc/" << m_CacheClient->Namespace() << "/" << BucketId << "/" TESTING_PREFIX << Key.ToHexString(); 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()}); + + if (Data.Value.GetContentType() == ZenContentType::kCbObject) + { + CbObjectView Cbo(Data.Value.Data()); + const IoHash Hash = Cbo.GetHash(); + const MemoryView DataView = Cbo.GetView(); + + Session.SetOption( + cpr::Header{{"Authorization", Auth}, {"X-Jupiter-IoHash", Hash.ToHexString()}, {"Content-Type", "application/x-ue-cb"}}); + + Session.SetOption(cpr::Body{reinterpret_cast<const char*>(DataView.GetData()), DataView.GetSize()}); + } + else + { + const IoHash Hash = IoHash::HashMemory(Data.Value.Data(), Data.Value.Size()); + + Session.SetOption( + cpr::Header{{"Authorization", Auth}, {"X-Jupiter-IoHash", Hash.ToHexString()}, {"Content-Type", "application/x-ue-cb"}}); + + Session.SetOption(cpr::Body{reinterpret_cast<const char*>(Data.Value.Data()), Data.Value.Size()}); + } cpr::Response Response = Session.Put(); |