aboutsummaryrefslogtreecommitdiffstats
path: root/yt/cpp/mapreduce/http/http.h
diff options
context:
space:
mode:
authorermolovd <ermolovd@yandex-team.com>2024-11-19 10:54:24 +0300
committerermolovd <ermolovd@yandex-team.com>2024-11-19 11:06:45 +0300
commit7be946f684e606f5baa9e3a13401cc19b8ac9a3b (patch)
treea4d6ce2a580ba953a048a64bdedbda1f6c7a1d26 /yt/cpp/mapreduce/http/http.h
parent907667c6ffd6222845fe8e18fd548e508250b5d0 (diff)
downloadydb-7be946f684e606f5baa9e3a13401cc19b8ac9a3b.tar.gz
YT-22943: add context for system errors
* thrown system errors contain context (i.e. host method and request id that produced error) Type: feature Component: cpp-sdk commit_hash:af72a3a37785e9e373e816c2cc072df2076f821d
Diffstat (limited to 'yt/cpp/mapreduce/http/http.h')
-rw-r--r--yt/cpp/mapreduce/http/http.h38
1 files changed, 22 insertions, 16 deletions
diff --git a/yt/cpp/mapreduce/http/http.h b/yt/cpp/mapreduce/http/http.h
index 013b40aecb..618b1e2c22 100644
--- a/yt/cpp/mapreduce/http/http.h
+++ b/yt/cpp/mapreduce/http/http.h
@@ -39,6 +39,12 @@ enum class EFrameType
KeepAlive = 0x02,
};
+struct TRequestContext
+{
+ TString RequestId;
+ TString HostName;
+ TString Method;
+};
class THttpHeader
{
@@ -171,9 +177,10 @@ public:
// 'requestId' and 'hostName' are provided for debug reasons
// (they will appear in some error messages).
THttpResponse(
- IInputStream* socketStream,
- const TString& requestId,
- const TString& hostName);
+ TRequestContext context,
+ IInputStream* socketStream);
+
+ ~THttpResponse();
const THttpHeaders& Headers() const;
@@ -195,13 +202,14 @@ private:
bool RefreshFrameIfNecessary();
private:
- const TString RequestId_;
+ class THttpInputWrapped;
- THttpInput HttpInput_;
+private:
+ THolder<THttpInputWrapped> HttpInput_;
- const TString HostName_;
const bool Unframe_;
+ TRequestContext Context_;
int HttpCode_ = 0;
TMaybe<TErrorResponse> ErrorResponse_;
bool IsExhausted_ = false;
@@ -213,18 +221,15 @@ private:
class THttpRequest
{
public:
- THttpRequest();
- THttpRequest(const TString& requestId);
+ THttpRequest(TString requestId, TString hostName, THttpHeader header, TDuration socketTimeout);
~THttpRequest();
TString GetRequestId() const;
- void Connect(TString hostName, TDuration socketTimeout = TDuration::Zero());
-
- IOutputStream* StartRequest(const THttpHeader& header);
+ IOutputStream* StartRequest();
void FinishRequest();
- void SmallRequest(const THttpHeader& header, TMaybe<TStringBuf> body);
+ void SmallRequest(TMaybe<TStringBuf> body);
THttpResponse* GetResponseStream();
@@ -235,16 +240,17 @@ public:
int GetHttpCode();
private:
- IOutputStream* StartRequestImpl(const THttpHeader& header, bool includeParameters);
+ IOutputStream* StartRequestImpl(bool includeParameters);
private:
class TRequestStream;
private:
- const TString RequestId_;
+ const TRequestContext Context_;
+ const THttpHeader Header_;
+ const TString Url_;
+ const TDuration SocketTimeout_;
- TString HostName_;
- TString Url_;
TInstant StartTime_;
TString LoggedAttributes_;