diff options
Diffstat (limited to 'src/buildtool/serve_api/remote/serve_api.hpp')
-rw-r--r-- | src/buildtool/serve_api/remote/serve_api.hpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/buildtool/serve_api/remote/serve_api.hpp b/src/buildtool/serve_api/remote/serve_api.hpp index 98966e6a..510881cb 100644 --- a/src/buildtool/serve_api/remote/serve_api.hpp +++ b/src/buildtool/serve_api/remote/serve_api.hpp @@ -37,10 +37,8 @@ class ServeApi final {}; class ServeApi final { public: - [[nodiscard]] static auto Instance() noexcept -> ServeApi const& { - static ServeApi instance = ServeApi::init(); - return instance; - } + explicit ServeApi(ServerAddress const& address) noexcept + : stc_{address}, tc_{address}, cc_{address} {} ~ServeApi() noexcept = default; ServeApi(ServeApi const&) = delete; @@ -48,6 +46,15 @@ class ServeApi final { auto operator=(ServeApi const&) -> ServeApi& = delete; auto operator=(ServeApi&&) -> ServeApi& = delete; + [[nodiscard]] static auto Create( + RemoteServeConfig const& serve_config) noexcept + -> std::optional<ServeApi> { + if (auto address = serve_config.RemoteAddress()) { + return std::make_optional<ServeApi>(*address); + } + return std::nullopt; + } + [[nodiscard]] auto RetrieveTreeFromCommit(std::string const& commit, std::string const& subdir = ".", bool sync_tree = false) @@ -130,14 +137,6 @@ class ServeApi final { } private: - explicit ServeApi(ServerAddress const& address) noexcept - : stc_{address}, tc_{address}, cc_{address} {} - - [[nodiscard]] static auto init() noexcept -> ServeApi { - auto sadd = RemoteServeConfig::Instance().RemoteAddress(); - return ServeApi{*sadd}; - } - // source tree service client SourceTreeClient const stc_; // target service client |