From 9a51bf81a860adb2f53794172d049b614739f14d Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Thu, 13 Jun 2024 14:25:44 +0200 Subject: Make RemoteServeConfig a general struct, not a singleton ...and adjust interfaces. --- src/buildtool/serve_api/remote/config.hpp | 85 +++---------------------------- 1 file changed, 6 insertions(+), 79 deletions(-) (limited to 'src/buildtool/serve_api/remote/config.hpp') diff --git a/src/buildtool/serve_api/remote/config.hpp b/src/buildtool/serve_api/remote/config.hpp index 4e5c3c21..8c46a853 100644 --- a/src/buildtool/serve_api/remote/config.hpp +++ b/src/buildtool/serve_api/remote/config.hpp @@ -32,96 +32,23 @@ struct RemoteServeConfig final { class Builder; - // Obtain global instance - [[nodiscard]] static auto Instance() noexcept -> RemoteServeConfig& { - static RemoteServeConfig config; - return config; - } - - // Set remote execution and cache address, unsets if parsing `address` fails - [[nodiscard]] auto SetRemoteAddress(std::string const& value) noexcept - -> bool { - return static_cast(remote_address = ParseAddress(value)); - } - - // Set the list of known repositories - [[nodiscard]] auto SetKnownRepositories( - std::vector const& value) noexcept -> bool { - known_repositories = std::vector( - std::make_move_iterator(value.begin()), - std::make_move_iterator(value.end())); - return value.size() == known_repositories.size(); - } - - // Set the number of jobs - [[nodiscard]] auto SetJobs(std::size_t value) noexcept -> bool { - return static_cast(jobs = value); - } - - // Set the number of build jobs - [[nodiscard]] auto SetBuildJobs(std::size_t value) noexcept -> bool { - return static_cast(build_jobs = value); - } - - // Set the action timeout - [[nodiscard]] auto SetActionTimeout( - std::chrono::milliseconds const& value) noexcept -> bool { - action_timeout = value; - return action_timeout > std::chrono::seconds{0}; - } - - void SetTCStrategy(TargetCacheWriteStrategy value) noexcept { - tc_strategy = value; - } - - // Remote execution address, if set - [[nodiscard]] auto RemoteAddress() const noexcept - -> std::optional { - return remote_address; - } - - // Repositories known to 'just serve' - [[nodiscard]] auto KnownRepositories() const noexcept - -> const std::vector& { - return known_repositories; - } - - // Get the number of jobs - [[nodiscard]] auto Jobs() const noexcept -> std::size_t { return jobs; } - - // Get the number of build jobs - [[nodiscard]] auto BuildJobs() const noexcept -> std::size_t { - return build_jobs; - } - - // Get the action timeout - [[nodiscard]] auto ActionTimeout() const noexcept - -> std::chrono::milliseconds { - return action_timeout; - } - - // Get the target-level cache write strategy - [[nodiscard]] auto TCStrategy() const noexcept -> TargetCacheWriteStrategy { - return tc_strategy; - } - // Server address of remote execution. - std::optional remote_address{}; + std::optional const remote_address{}; // Known Git repositories to serve server. - std::vector known_repositories{}; + std::vector const known_repositories{}; // Number of jobs - std::size_t jobs = 0; + std::size_t const jobs = 0; // Number of build jobs - std::size_t build_jobs = 0; + std::size_t const build_jobs = 0; // Action timeout - std::chrono::milliseconds action_timeout{}; + std::chrono::milliseconds const action_timeout{}; // Strategy for synchronizing target-level cache - TargetCacheWriteStrategy tc_strategy{TargetCacheWriteStrategy::Sync}; + TargetCacheWriteStrategy const tc_strategy{TargetCacheWriteStrategy::Sync}; }; class RemoteServeConfig::Builder final { -- cgit v1.2.3