aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/buildstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver/buildstore')
-rw-r--r--src/zenserver/buildstore/buildstore.cpp75
-rw-r--r--src/zenserver/buildstore/buildstore.h30
-rw-r--r--src/zenserver/buildstore/httpbuildstore.cpp28
-rw-r--r--src/zenserver/buildstore/httpbuildstore.h28
4 files changed, 161 insertions, 0 deletions
diff --git a/src/zenserver/buildstore/buildstore.cpp b/src/zenserver/buildstore/buildstore.cpp
new file mode 100644
index 000000000..81dffc09c
--- /dev/null
+++ b/src/zenserver/buildstore/buildstore.cpp
@@ -0,0 +1,75 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#include "buildstore.h"
+
+#include <zencore/testing.h>
+#include <zencore/testutils.h>
+
+#include <zencore/uid.h>
+#include <zencore/xxhash.h>
+
+namespace zen {
+
+BuildStore::BuildStore(BuildStoreConfig Config)
+{
+ const uint64_t MaxBlockSize = 256 * 1024 * 1024;
+ const uint64_t MaxBlockCount = 32 * 1024;
+ m_BlockStore.Initialize(Config.RootDirectory, MaxBlockSize, MaxBlockCount);
+}
+
+BuildStore::~BuildStore()
+{
+}
+
+// TODO: reconsider key size
+inline Oid
+IdFromKey(std::string_view Key)
+{
+ XXH3_128 Hash = XXH3_128::HashMemory(Key.data(), Key.size());
+
+ Oid Id;
+ memcpy(&Id.OidBits, Hash.Hash, sizeof Id);
+ return Id;
+}
+
+void
+BuildStore::Put(std::string_view Key, IoBuffer Value)
+{
+ ZEN_UNUSED(Key, Value);
+}
+
+IoBuffer
+BuildStore::Get(std::string_view Key)
+{
+ ZEN_UNUSED(Key);
+ return {};
+}
+
+/*
+ ___________ __
+ \__ ___/___ _______/ |_ ______
+ | |_/ __ \ / ___/\ __\/ ___/
+ | |\ ___/ \___ \ | | \___ \
+ |____| \___ >____ > |__| /____ >
+ \/ \/ \/
+*/
+
+#if ZEN_WITH_TESTS
+
+TEST_CASE("BuildStore")
+{
+ ScopedTemporaryDirectory _;
+
+ BuildStoreConfig Config;
+ Config.RootDirectory = _.Path() / "build_store";
+ BuildStore Store(Config);
+}
+
+void
+buildstore_forcelink()
+{
+}
+
+#endif
+
+} // namespace zen
diff --git a/src/zenserver/buildstore/buildstore.h b/src/zenserver/buildstore/buildstore.h
new file mode 100644
index 000000000..b2801fc7f
--- /dev/null
+++ b/src/zenserver/buildstore/buildstore.h
@@ -0,0 +1,30 @@
+
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#include <zenstore/blockstore.h>
+
+#include <filesystem>
+
+namespace zen {
+
+struct BuildStoreConfig
+{
+ std::filesystem::path RootDirectory;
+};
+
+class BuildStore
+{
+public:
+ BuildStore(BuildStoreConfig Config);
+ ~BuildStore();
+
+ void Put(std::string_view Key, IoBuffer Value);
+ IoBuffer Get(std::string_view Key);
+
+private:
+ BlockStore m_BlockStore;
+};
+
+void buildstore_forcelink();
+
+} // namespace zen
diff --git a/src/zenserver/buildstore/httpbuildstore.cpp b/src/zenserver/buildstore/httpbuildstore.cpp
new file mode 100644
index 000000000..1a0998c15
--- /dev/null
+++ b/src/zenserver/buildstore/httpbuildstore.cpp
@@ -0,0 +1,28 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#include "httpbuildstore.h"
+
+namespace zen {
+
+HttpBuildStoreService::HttpBuildStoreService(BuildStoreConfig Cfg) : m_Config(Cfg)
+{
+ m_BuildStore = std::make_unique<BuildStore>(m_Config);
+}
+
+HttpBuildStoreService::~HttpBuildStoreService()
+{
+}
+
+const char*
+HttpBuildStoreService::HttpBuildStoreService::BaseUri() const
+{
+ return "/builds/";
+}
+
+void
+HttpBuildStoreService::HandleRequest(zen::HttpServerRequest& Request)
+{
+ ZEN_UNUSED(Request);
+}
+
+} // namespace zen
diff --git a/src/zenserver/buildstore/httpbuildstore.h b/src/zenserver/buildstore/httpbuildstore.h
new file mode 100644
index 000000000..d34035d0f
--- /dev/null
+++ b/src/zenserver/buildstore/httpbuildstore.h
@@ -0,0 +1,28 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#pragma once
+
+#include "buildstore.h"
+
+#include <zenhttp/httpserver.h>
+
+#include <filesystem>
+
+namespace zen {
+
+class HttpBuildStoreService final : public zen::HttpService
+{
+public:
+ HttpBuildStoreService(BuildStoreConfig Cfg);
+ virtual ~HttpBuildStoreService();
+
+ virtual const char* BaseUri() const override;
+ virtual void HandleRequest(zen::HttpServerRequest& Request) override;
+
+private:
+ BuildStoreConfig m_Config;
+
+ std::unique_ptr<BuildStore> m_BuildStore;
+};
+
+} // namespace zen