summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildtool/execution_api')
-rw-r--r--src/buildtool/execution_api/common/TARGETS1
-rw-r--r--src/buildtool/execution_api/common/api_bundle.cpp29
-rw-r--r--src/buildtool/execution_api/common/api_bundle.hpp20
3 files changed, 30 insertions, 20 deletions
diff --git a/src/buildtool/execution_api/common/TARGETS b/src/buildtool/execution_api/common/TARGETS
index f5164662..88eddf05 100644
--- a/src/buildtool/execution_api/common/TARGETS
+++ b/src/buildtool/execution_api/common/TARGETS
@@ -48,6 +48,7 @@
, ["src/buildtool/common/remote", "retry_config"]
, ["src/buildtool/execution_api/local", "context"]
, ["src/buildtool/execution_api/remote", "config"]
+ , ["src/buildtool/execution_api/remote", "context"]
, ["src/buildtool/crypto", "hash_function"]
]
, "private-deps":
diff --git a/src/buildtool/execution_api/common/api_bundle.cpp b/src/buildtool/execution_api/common/api_bundle.cpp
index edb29970..f587a91b 100644
--- a/src/buildtool/execution_api/common/api_bundle.cpp
+++ b/src/buildtool/execution_api/common/api_bundle.cpp
@@ -14,25 +14,26 @@
#include "src/buildtool/execution_api/common/api_bundle.hpp"
-#include "src/buildtool/common/remote/retry_config.hpp"
#include "src/buildtool/execution_api/bazel_msg/bazel_common.hpp"
#include "src/buildtool/execution_api/local/local_api.hpp"
#include "src/buildtool/execution_api/remote/bazel/bazel_api.hpp"
-ApiBundle::ApiBundle(
- gsl::not_null<LocalContext const*> const& local_context,
- RepositoryConfig const* repo_config,
- gsl::not_null<Auth const*> const& authentication,
- gsl::not_null<RetryConfig const*> const& retry_config,
- gsl::not_null<RemoteExecutionConfig const*> const& remote_exec_config)
- : auth{*authentication},
- retry_config{*retry_config},
- remote_config{*remote_exec_config},
+ApiBundle::ApiBundle(gsl::not_null<LocalContext const*> const& local_context,
+ gsl::not_null<RemoteContext const*> const& remote_context,
+ RepositoryConfig const* repo_config)
+ : auth{*remote_context->auth},
+ retry_config{*remote_context->retry_config},
+ remote_config{*remote_context->exec_config},
hash_function{local_context->storage_config->hash_function},
local{std::make_shared<LocalApi>(local_context, repo_config)},
- remote{CreateRemote(remote_exec_config->remote_address)} {}
+ remote{CreateRemote(remote_context->exec_config->remote_address,
+ remote_context->auth,
+ remote_context->retry_config)} {}
-auto ApiBundle::CreateRemote(std::optional<ServerAddress> const& address) const
+auto ApiBundle::CreateRemote(
+ std::optional<ServerAddress> const& address,
+ gsl::not_null<Auth const*> const& authentication,
+ gsl::not_null<RetryConfig const*> const& retry_config) const
-> gsl::not_null<IExecutionApi::Ptr> {
if (address) {
ExecutionConfiguration config;
@@ -40,8 +41,8 @@ auto ApiBundle::CreateRemote(std::optional<ServerAddress> const& address) const
return std::make_shared<BazelApi>("remote-execution",
address->host,
address->port,
- &auth,
- &retry_config,
+ authentication,
+ retry_config,
config,
hash_function);
}
diff --git a/src/buildtool/execution_api/common/api_bundle.hpp b/src/buildtool/execution_api/common/api_bundle.hpp
index d6cf4423..7d524b2e 100644
--- a/src/buildtool/execution_api/common/api_bundle.hpp
+++ b/src/buildtool/execution_api/common/api_bundle.hpp
@@ -27,6 +27,7 @@
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/execution_api/local/context.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
+#include "src/buildtool/execution_api/remote/context.hpp"
/// \brief Utility structure for instantiation of local and remote apis at the
/// same time. If the remote api cannot be instantiated, it falls back to
@@ -34,13 +35,20 @@
struct ApiBundle final {
explicit ApiBundle(
gsl::not_null<LocalContext const*> const& local_context,
- RepositoryConfig const* repo_config,
- gsl::not_null<Auth const*> const& authentication,
- gsl::not_null<RetryConfig const*> const& retry_config,
- gsl::not_null<RemoteExecutionConfig const*> const& remote_exec_config);
+ gsl::not_null<RemoteContext const*> const& remote_context,
+ RepositoryConfig const* repo_config);
- [[nodiscard]] auto CreateRemote(std::optional<ServerAddress> const& address)
- const -> gsl::not_null<IExecutionApi::Ptr>;
+ /// \brief Create a Remote object based on the given arguments.
+ /// \param address The endpoint address.
+ /// \param authentication The remote authentication configuration.
+ /// \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(
+ std::optional<ServerAddress> const& address,
+ gsl::not_null<Auth const*> const& authentication,
+ gsl::not_null<RetryConfig const*> const& retry_config) const
+ -> gsl::not_null<IExecutionApi::Ptr>;
// Needed to be set before creating the remote (via CreateRemote)
Auth const& auth;