aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/compute/function.h
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-05-02 10:01:47 +0200
committerGitHub <[email protected]>2023-05-02 10:01:47 +0200
commit075d17f8ada47e990fe94606c3d21df409223465 (patch)
treee50549b766a2f3c354798a54ff73404217b4c9af /src/zenserver/compute/function.h
parentfix: bundle shouldn't append content zip to zen (diff)
downloadzen-075d17f8ada47e990fe94606c3d21df409223465.tar.xz
zen-075d17f8ada47e990fe94606c3d21df409223465.zip
moved source directories into `/src` (#264)
* moved source directories into `/src` * updated bundle.lua for new `src` path * moved some docs, icon * removed old test trees
Diffstat (limited to 'src/zenserver/compute/function.h')
-rw-r--r--src/zenserver/compute/function.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/zenserver/compute/function.h b/src/zenserver/compute/function.h
new file mode 100644
index 000000000..650cee757
--- /dev/null
+++ b/src/zenserver/compute/function.h
@@ -0,0 +1,73 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#pragma once
+
+#include <zencore/zencore.h>
+
+#if !defined(ZEN_WITH_COMPUTE_SERVICES)
+# define ZEN_WITH_COMPUTE_SERVICES 1
+#endif
+
+#if ZEN_WITH_COMPUTE_SERVICES
+
+# include <zencore/compactbinary.h>
+# include <zencore/iohash.h>
+# include <zencore/logging.h>
+# include <zenhttp/httpserver.h>
+
+# include <filesystem>
+# include <unordered_map>
+
+namespace zen {
+
+class CidStore;
+class UpstreamApply;
+class CloudCacheClient;
+class AuthMgr;
+
+struct UpstreamAuthConfig;
+struct CloudCacheClientOptions;
+
+/**
+ * Lambda style compute function service
+ */
+class HttpFunctionService : public HttpService
+{
+public:
+ HttpFunctionService(CidStore& InCidStore,
+ const CloudCacheClientOptions& ComputeOptions,
+ const CloudCacheClientOptions& StorageOptions,
+ const UpstreamAuthConfig& ComputeAuthConfig,
+ const UpstreamAuthConfig& StorageAuthConfig,
+ AuthMgr& Mgr);
+ ~HttpFunctionService();
+
+ virtual const char* BaseUri() const override;
+ virtual void HandleRequest(HttpServerRequest& Request) override;
+
+private:
+ std::thread InitializeThread;
+ spdlog::logger& Log() { return m_Log; }
+ spdlog::logger& m_Log;
+ HttpRequestRouter m_Router;
+ CidStore& m_CidStore;
+ std::unique_ptr<UpstreamApply> m_UpstreamApply;
+
+ struct WorkerDesc
+ {
+ CbObject Descriptor;
+ };
+
+ [[nodiscard]] HttpResponseCode ExecActionUpstream(const WorkerDesc& Worker, CbObject& Object);
+ [[nodiscard]] HttpResponseCode ExecActionUpstreamResult(const IoHash& WorkerId, CbObject& Object);
+
+ [[nodiscard]] HttpResponseCode ExecActionUpstream(const WorkerDesc& Worker, CbObject Action, CbObject& Object);
+ [[nodiscard]] HttpResponseCode ExecActionUpstreamResult(const IoHash& WorkerId, const IoHash& ActionId, CbPackage& Package);
+
+ RwLock m_WorkerLock;
+ std::unordered_map<IoHash, WorkerDesc> m_WorkerMap;
+};
+
+} // namespace zen
+
+#endif // ZEN_WITH_COMPUTE_SERVICES