diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-06-13 14:25:44 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-06-18 12:05:10 +0200 |
commit | 9a51bf81a860adb2f53794172d049b614739f14d (patch) | |
tree | 1086585c55c5e8a4ff83afe88e9f7c80796c3bc9 /src/buildtool/serve_api/remote/config.hpp | |
parent | 05b734f11b7a45a1da5c38fcc1f27780c3fe4354 (diff) | |
download | justbuild-9a51bf81a860adb2f53794172d049b614739f14d.tar.gz |
Make RemoteServeConfig a general struct, not a singleton
...and adjust interfaces.
Diffstat (limited to 'src/buildtool/serve_api/remote/config.hpp')
-rw-r--r-- | src/buildtool/serve_api/remote/config.hpp | 85 |
1 files changed, 6 insertions, 79 deletions
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<bool>(remote_address = ParseAddress(value)); - } - - // Set the list of known repositories - [[nodiscard]] auto SetKnownRepositories( - std::vector<std::filesystem::path> const& value) noexcept -> bool { - known_repositories = std::vector<std::filesystem::path>( - 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<bool>(jobs = value); - } - - // Set the number of build jobs - [[nodiscard]] auto SetBuildJobs(std::size_t value) noexcept -> bool { - return static_cast<bool>(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<ServerAddress> { - return remote_address; - } - - // Repositories known to 'just serve' - [[nodiscard]] auto KnownRepositories() const noexcept - -> const std::vector<std::filesystem::path>& { - 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<ServerAddress> remote_address{}; + std::optional<ServerAddress> const remote_address{}; // Known Git repositories to serve server. - std::vector<std::filesystem::path> known_repositories{}; + std::vector<std::filesystem::path> 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 { |