summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/execution_service/server_implementation.hpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-18 10:12:15 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-22 18:44:29 +0200
commit69a5e84e420aa16022baeb146931cd6da43f6305 (patch)
treeaf74c8e23dc41bcbaaa97a697510fa1019f88cac /src/buildtool/execution_api/execution_service/server_implementation.hpp
parentc046489012d3d30a46b94c8047256fd41e8076c9 (diff)
downloadjustbuild-69a5e84e420aa16022baeb146931cd6da43f6305.tar.gz
Make ServerImpl a general class, not singleton
Diffstat (limited to 'src/buildtool/execution_api/execution_service/server_implementation.hpp')
-rw-r--r--src/buildtool/execution_api/execution_service/server_implementation.hpp39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/buildtool/execution_api/execution_service/server_implementation.hpp b/src/buildtool/execution_api/execution_service/server_implementation.hpp
index 97264fe1..d9e16dad 100644
--- a/src/buildtool/execution_api/execution_service/server_implementation.hpp
+++ b/src/buildtool/execution_api/execution_service/server_implementation.hpp
@@ -24,40 +24,37 @@
#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/storage.hpp"
-class ServerImpl {
+class ServerImpl final {
public:
- ServerImpl() noexcept = default;
- [[nodiscard]] static auto Instance() noexcept -> ServerImpl& {
- static ServerImpl x;
- return x;
- }
-
- [[nodiscard]] static auto SetInterface(std::string const& x) noexcept
- -> bool {
- Instance().interface_ = x;
- return true;
- }
-
- [[nodiscard]] static auto SetPidFile(std::string const& x) noexcept -> bool;
+ [[nodiscard]] static auto Create(
+ std::optional<std::string> interface,
+ std::optional<int> port,
+ std::optional<std::string> info_file,
+ std::optional<std::string> pid_file) noexcept
+ -> std::optional<ServerImpl>;
- [[nodiscard]] static auto SetPort(int x) noexcept -> bool;
-
- [[nodiscard]] static auto SetInfoFile(std::string const& x) noexcept
- -> bool;
+ ~ServerImpl() noexcept = default;
ServerImpl(ServerImpl const&) = delete;
auto operator=(ServerImpl const&) noexcept -> ServerImpl& = delete;
- ServerImpl(ServerImpl&&) noexcept = delete;
- auto operator=(ServerImpl&&) noexcept -> ServerImpl& = delete;
+ ServerImpl(ServerImpl&&) noexcept = default;
+ auto operator=(ServerImpl&&) noexcept -> ServerImpl& = default;
+ /// \brief Start the execution service.
+ /// \param storage_config StorageConfig to be used.
+ /// \param storage Storage to be used.
+ /// \param apis Apis to be used, only local api is actually
+ /// needed.
+ /// \param op_exponent Log2 threshold for operation cache.
auto Run(StorageConfig const& storage_config,
Storage const& storage,
ApiBundle const& apis,
std::optional<std::uint8_t> op_exponent) -> bool;
- ~ServerImpl() = default;
private:
+ ServerImpl() noexcept = default;
+
std::string interface_{"127.0.0.1"};
int port_{0};
std::string info_file_{};