#pragma once #include #include #include namespace NYT::NDetail { //////////////////////////////////////////////////////////////////////////////// class TRpcRawBatchRequest : public IRawBatchRequest { public: TRpcRawBatchRequest( IRawClientPtr rawClient, const TConfigPtr& config); void ExecuteBatch(const TExecuteBatchOptions& options = {}) override; ::NThreading::TFuture Create( const TTransactionId& transactionId, const TYPath& path, ENodeType type, const TCreateOptions& options = {}) override; ::NThreading::TFuture Remove( const TTransactionId& transactionId, const TYPath& path, const TRemoveOptions& options = {}) override; ::NThreading::TFuture Exists( const TTransactionId& transactionId, const TYPath& path, const TExistsOptions& options = {}) override; ::NThreading::TFuture Get( const TTransactionId& transactionId, const TYPath& path, const TGetOptions& options = {}) override; ::NThreading::TFuture Set( const TTransactionId& transactionId, const TYPath& path, const TNode& value, const TSetOptions& options = {}) override; ::NThreading::TFuture List( const TTransactionId& transactionId, const TYPath& path, const TListOptions& options = {}) override; ::NThreading::TFuture Copy( const TTransactionId& transactionId, const TYPath& sourcePath, const TYPath& destinationPath, const TCopyOptions& options = {}) override; ::NThreading::TFuture Move( const TTransactionId& transactionId, const TYPath& sourcePath, const TYPath& destinationPath, const TMoveOptions& options = {}) override; ::NThreading::TFuture Link( const TTransactionId& transactionId, const TYPath& targetPath, const TYPath& linkPath, const TLinkOptions& options = {}) override; ::NThreading::TFuture Lock( const TTransactionId& transactionId, const TYPath& path, ELockMode mode, const TLockOptions& options = {}) override; ::NThreading::TFuture Unlock( const TTransactionId& transactionId, const TYPath& path, const TUnlockOptions& options = {}) override; ::NThreading::TFuture> GetFileFromCache( const TTransactionId& transactionId, const TString& md5Signature, const TYPath& cachePath, const TGetFileFromCacheOptions& options = {}) override; ::NThreading::TFuture PutFileToCache( const TTransactionId& transactionId, const TYPath& filePath, const TString& md5Signature, const TYPath& cachePath, const TPutFileToCacheOptions& options = {}) override; ::NThreading::TFuture CheckPermission( const TString& user, EPermission permission, const TYPath& path, const TCheckPermissionOptions& options = {}) override; ::NThreading::TFuture GetOperation( const TOperationId& operationId, const TGetOperationOptions& options = {}) override; ::NThreading::TFuture AbortOperation(const TOperationId& operationId) override; ::NThreading::TFuture CompleteOperation(const TOperationId& operationId) override; ::NThreading::TFuture SuspendOperation( const TOperationId& operationId, const TSuspendOperationOptions& options = {}) override; ::NThreading::TFuture ResumeOperation( const TOperationId& operationId, const TResumeOperationOptions& options = {}) override; ::NThreading::TFuture UpdateOperationParameters( const TOperationId& operationId, const TUpdateOperationParametersOptions& options = {}) override; ::NThreading::TFuture CanonizeYPath(const TRichYPath& path) override; ::NThreading::TFuture> GetTableColumnarStatistics( const TTransactionId& transactionId, const TVector& paths, const TGetTableColumnarStatisticsOptions& options = {}) override; ::NThreading::TFuture GetTablePartitions( const TTransactionId& transactionId, const TVector& paths, const TGetTablePartitionsOptions& options = {}) override; private: struct ISingleRequest : public TThrRefBase { virtual void Invoke() = 0; }; template class TSingleRequest : public ISingleRequest { public: TSingleRequest( IRequestRetryPolicyPtr retryPolicy, std::function request); ::NThreading::TFuture GetFuture(); void Invoke() override; private: const IRequestRetryPolicyPtr RequestRetryPolicy_; ::NThreading::TPromise Result_; std::function Request_; }; private: const IRawClientPtr RawClient_; const TConfigPtr Config_; std::queue> Requests_; bool Executed_ = false; template auto AddRequest(TRequest&& request) -> decltype(request->GetFuture()) { Y_ENSURE(!Executed_, "Cannot add request: batch request is already executed"); auto future = request->GetFuture(); Requests_.emplace(std::forward(request)); return future; } }; //////////////////////////////////////////////////////////////////////////////// } // namespace NYT::NDetail