aboutsummaryrefslogtreecommitdiff
path: root/zenserver
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-05-20 14:07:02 +0200
committerStefan Boberg <[email protected]>2021-05-20 14:07:02 +0200
commit13f29372ccf31997bc0d71984b911d96ee01bba5 (patch)
treefc9a47895c62fc7109f932a9d5dce2718a7a38e7 /zenserver
parentAdded tentative Jupiter structured data endpoints (diff)
parentUpdate README.md (diff)
downloadzen-13f29372ccf31997bc0d71984b911d96ee01bba5.tar.xz
zen-13f29372ccf31997bc0d71984b911d96ee01bba5.zip
Merged from master
Diffstat (limited to 'zenserver')
-rw-r--r--zenserver/upstream/jupiter.cpp40
-rw-r--r--zenserver/upstream/jupiter.h4
-rw-r--r--zenserver/zenserver.vcxproj2
3 files changed, 46 insertions, 0 deletions
diff --git a/zenserver/upstream/jupiter.cpp b/zenserver/upstream/jupiter.cpp
index 88a164fbd..1078e5240 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,6 +109,45 @@ CloudCacheSession::Put(std::string_view BucketId, std::string_view Key, IoBuffer
}
}
+void
+CloudCacheSession::Put(std::string_view BucketId, std::string_view Key, CbObjectView Data)
+{
+ ExtendableStringBuilder<256> Uri;
+ Uri << m_CacheClient->ServiceUrl();
+ Uri << "/api/v1/c/ddc/" << m_CacheClient->Namespace() << "/" << BucketId << "/" TESTING_PREFIX << Key;
+
+ 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);
+ }
+}
+
+std::vector<IoHash>
+CloudCacheSession::Filter(std::string_view BucketId, const std::vector<IoHash>& ChunkHashes)
+{
+ ExtendableStringBuilder<256> Uri;
+ Uri << m_CacheClient->ServiceUrl();
+ Uri << "/api/v1/s/" << m_CacheClient->Namespace();
+
+ ZEN_UNUSED(BucketId, ChunkHashes);
+
+ return {};
+}
+
//////////////////////////////////////////////////////////////////////////
IoBuffer
diff --git a/zenserver/upstream/jupiter.h b/zenserver/upstream/jupiter.h
index c17ffb047..2f01b7afb 100644
--- a/zenserver/upstream/jupiter.h
+++ b/zenserver/upstream/jupiter.h
@@ -9,6 +9,7 @@
#include <atomic>
#include <list>
#include <memory>
+#include <vector>
namespace zen {
namespace detail {
@@ -18,6 +19,7 @@ namespace detail {
class IoBuffer;
class CloudCacheClient;
struct IoHash;
+class CbObjectView;
/**
* Cached access token, for use with `Authorization:` header
@@ -56,6 +58,8 @@ public:
IoBuffer Get(std::string_view BucketId, const IoHash& Key);
void Put(std::string_view BucketId, const IoHash& Key, IoBuffer Data, HttpContentType ContentType);
+ std::vector<IoHash> Filter(std::string_view BucketId, const std::vector<IoHash>& ChunkHashes);
+
private:
RefPtr<CloudCacheClient> m_CacheClient;
detail::CloudCacheSessionState* m_SessionState;
diff --git a/zenserver/zenserver.vcxproj b/zenserver/zenserver.vcxproj
index b47ec2f04..2ba6bd551 100644
--- a/zenserver/zenserver.vcxproj
+++ b/zenserver/zenserver.vcxproj
@@ -58,10 +58,12 @@
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<VcpkgEnableManifest>true</VcpkgEnableManifest>
<VcpkgUseStatic>true</VcpkgUseStatic>
+ <VcpkgAdditionalInstallOptions>--overlay-ports=$(SolutionDir)vcpkg_overlay-ports</VcpkgAdditionalInstallOptions>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<VcpkgEnableManifest>true</VcpkgEnableManifest>
<VcpkgUseStatic>true</VcpkgUseStatic>
+ <VcpkgAdditionalInstallOptions>--overlay-ports=$(SolutionDir)vcpkg_overlay-ports</VcpkgAdditionalInstallOptions>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>