From b393090c220da61dd1c197adfac42dc47ad74f8a Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 29 Jul 2024 11:13:08 +0200 Subject: ApiBundle: Use a creator method instead of constructor This will allow for ApiBundle to be used together with the TestApi implementation of IExecutionApi in tests. Also rename CreateRemote method to MakeRemote in order to remove any semantical confusion. --- src/buildtool/execution_api/common/api_bundle.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/buildtool/execution_api/common/api_bundle.hpp') diff --git a/src/buildtool/execution_api/common/api_bundle.hpp b/src/buildtool/execution_api/common/api_bundle.hpp index 17c64d1e..28595010 100644 --- a/src/buildtool/execution_api/common/api_bundle.hpp +++ b/src/buildtool/execution_api/common/api_bundle.hpp @@ -29,10 +29,13 @@ /// same time. If the remote api cannot be instantiated, it falls back to /// exactly the same instance that local api is (&*remote == & *local). struct ApiBundle final { - explicit ApiBundle( + /// \brief Create an ApiBundle instance. + /// \note A creator method is used instead of a constructor to allow for + /// tests to instantiate ApiBundles with own implementations of the APIs. + [[nodiscard]] static auto Create( gsl::not_null const& local_context, gsl::not_null const& remote_context, - RepositoryConfig const* repo_config); + RepositoryConfig const* repo_config) -> ApiBundle; /// \brief Create a Remote object based on the given arguments. /// \param address The endpoint address. @@ -40,13 +43,12 @@ struct ApiBundle final { /// \param retry_config The retry strategy configuration. /// \returns A configured api: BazelApi if a remote address is given, /// otherwise fall back to the already configured LocalApi instance. - [[nodiscard]] auto CreateRemote( + [[nodiscard]] auto MakeRemote( std::optional const& address, gsl::not_null const& authentication, gsl::not_null const& retry_config) const -> gsl::not_null; - // Needed to be set before creating the remote (via CreateRemote) HashFunction const hash_function; // 7 bytes of alignment. -- cgit v1.2.3