diff options
| author | Joe Kirchoff <[email protected]> | 2022-03-22 11:47:38 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-03-22 11:47:38 -0700 |
| commit | cc5adf4cb79c92993fabfe09e75dfadb7d4c9665 (patch) | |
| tree | 4ba0a18f68e39685fa784d872bbb4bb9ba2b6fd7 /zenserver/compute/function.h | |
| parent | move workthreadpool to zencore (#63) (diff) | |
| download | zen-cc5adf4cb79c92993fabfe09e75dfadb7d4c9665.tar.xz zen-cc5adf4cb79c92993fabfe09e75dfadb7d4c9665.zip | |
Enable Horde compute code on Linux & Mac (#61)
Diffstat (limited to 'zenserver/compute/function.h')
| -rw-r--r-- | zenserver/compute/function.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/zenserver/compute/function.h b/zenserver/compute/function.h new file mode 100644 index 000000000..962927f1c --- /dev/null +++ b/zenserver/compute/function.h @@ -0,0 +1,72 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include <zencore/zencore.h> + +#if !defined(ZEN_WITH_COMPUTE_SERVICES) +# define ZEN_WITH_COMPUTE_SERVICES ZEN_PLATFORM_WINDOWS +#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 CasStore; +class CidStore; +class UpstreamApply; +class CloudCacheClient; +class AuthMgr; + +struct UpstreamAuthConfig; +struct CloudCacheClientOptions; + +/** + * Lambda style compute function service + */ +class HttpFunctionService : public HttpService +{ +public: + HttpFunctionService(CasStore& Store, + 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: + spdlog::logger& Log() { return m_Log; } + spdlog::logger& m_Log; + HttpRequestRouter m_Router; + CasStore& m_CasStore; + CidStore& m_CidStore; + std::unique_ptr<UpstreamApply> m_UpstreamApply; + + struct WorkerDesc + { + CbObject Descriptor; + }; + + [[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 |