#pragma once #include #include #include #include namespace NYT { /////////////////////////////////////////////////////////////////////////////// class THeavyRequestRetrier { public: struct TParameters { IClientRetryPolicyPtr ClientRetryPolicy; ITransactionPingerPtr TransactionPinger; TClientContext Context; TTransactionId TransactionId; THttpHeader Header; }; using TStreamFactory = std::function()>; public: explicit THeavyRequestRetrier(TParameters parameters); ~THeavyRequestRetrier(); void Update(TStreamFactory streamFactory); void Finish(); private: void Retry(const std::function& function); void TryStartAttempt(); private: const TParameters Parameters_; const IRequestRetryPolicyPtr RequestRetryPolicy_; struct TAttempt { std::unique_ptr Transaction; TString RequestId; NHttpClient::IHttpRequestPtr Request; ssize_t Offset = 0; }; std::unique_ptr Attempt_; TStreamFactory StreamFactory_; }; /////////////////////////////////////////////////////////////////////////////// void RetryHeavyWriteRequest( const IClientRetryPolicyPtr& clientRetryPolicy, const ITransactionPingerPtr& transactionPinger, const TClientContext& context, const TTransactionId& parentId, THttpHeader& header, std::function()> streamMaker); //////////////////////////////////////////////////////////////////////////////// } // namespace NYT