// Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_BAZEL_BAZEL_API_HPP #define INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_BAZEL_BAZEL_API_HPP #include #include #include #include #include "gsl/gsl" #include "src/buildtool/common/artifact_digest.hpp" #include "src/buildtool/common/remote/port.hpp" #include "src/buildtool/execution_api/bazel_msg/bazel_common.hpp" #include "src/buildtool/execution_api/bazel_msg/blob_tree.hpp" #include "src/buildtool/execution_api/common/execution_api.hpp" #include "src/buildtool/execution_api/remote/config.hpp" // forward declaration for actual implementations class BazelNetwork; struct ExecutionConfiguration; /// \brief Bazel implementation of the abstract Execution API. class BazelApi final : public IExecutionApi { public: BazelApi(std::string const& instance_name, std::string const& host, Port port, ExecutionConfiguration const& exec_config) noexcept; BazelApi(BazelApi const&) = delete; BazelApi(BazelApi&& other) noexcept; auto operator=(BazelApi const&) -> BazelApi& = delete; auto operator=(BazelApi&&) -> BazelApi& = delete; ~BazelApi() final; auto CreateAction( ArtifactDigest const& root_digest, std::vector const& command, std::vector const& output_files, std::vector const& output_dirs, std::map const& env_vars, std::map const& properties) noexcept -> IExecutionAction::Ptr final; // NOLINTNEXTLINE(google-default-arguments) [[nodiscard]] auto RetrieveToPaths( std::vector const& artifacts_info, std::vector const& output_paths, IExecutionApi* alternative = nullptr) noexcept -> bool final; [[nodiscard]] auto RetrieveToFds( std::vector const& artifacts_info, std::vector const& fds, bool raw_tree) noexcept -> bool final; [[nodiscard]] auto ParallelRetrieveToCas( std::vector const& artifacts_info, gsl::not_null const& api, std::size_t jobs) noexcept -> bool final; [[nodiscard]] auto RetrieveToCas( std::vector const& artifacts_info, gsl::not_null const& api) noexcept -> bool final; [[nodiscard]] auto Upload(BlobContainer const& blobs, bool skip_find_missing) noexcept -> bool final; [[nodiscard]] auto UploadTree( std::vector const& artifacts) noexcept -> std::optional final; [[nodiscard]] auto IsAvailable(ArtifactDigest const& digest) const noexcept -> bool final; [[nodiscard]] auto IsAvailable(std::vector const& digests) const noexcept -> std::vector final; [[nodiscard]] auto RetrieveToMemory( Artifact::ObjectInfo const& artifact_info) -> std::optional final; private: std::shared_ptr network_; [[nodiscard]] auto UploadBlobTree(BlobTreePtr const& blob_tree) noexcept -> bool; }; #endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_BAZEL_BAZEL_API_HPP