retry_request.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include "fwd.h"
  3. #include <yt/cpp/mapreduce/interface/fwd.h>
  4. #include <yt/cpp/mapreduce/common/fwd.h>
  5. #include <yt/cpp/mapreduce/http/http_client.h>
  6. #include <util/datetime/base.h>
  7. #include <util/generic/maybe.h>
  8. #include <util/generic/string.h>
  9. namespace NYT::NDetail {
  10. ////////////////////////////////////////////////////////////////////
  11. struct TResponseInfo
  12. {
  13. TString RequestId;
  14. TString Response;
  15. int HttpCode = 0;
  16. };
  17. ////////////////////////////////////////////////////////////////////
  18. struct TRequestConfig
  19. {
  20. NHttpClient::THttpConfig HttpConfig;
  21. bool IsHeavy = false;
  22. };
  23. ////////////////////////////////////////////////////////////////////
  24. // Retry request with given `header' and `body' using `retryPolicy'.
  25. // If `retryPolicy == nullptr' use default, currently `TAttemptLimitedRetryPolicy(TConfig::Get()->RetryCount)`.
  26. TResponseInfo RetryRequestWithPolicy(
  27. IRequestRetryPolicyPtr retryPolicy,
  28. const TClientContext& context,
  29. THttpHeader& header,
  30. TMaybe<TStringBuf> body = {},
  31. const TRequestConfig& config = TRequestConfig());
  32. TResponseInfo RequestWithoutRetry(
  33. const TClientContext& context,
  34. THttpHeader& header,
  35. TMaybe<TStringBuf> body = {},
  36. const TRequestConfig& config = TRequestConfig());
  37. ////////////////////////////////////////////////////////////////////
  38. } // namespace NYT::NDetail