Skip to content

Commit b2939f5

Browse files
authored
transport: add error attributes indicating stream network state (grpc#28546)
* transport: add error attributes indicating stream network state * add missing case
1 parent 32b087e commit b2939f5

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

src/core/lib/gprpp/status_helper.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ const char* GetStatusIntPropertyUrl(StatusIntProperty key) {
8383
return TYPE_URL(TYPE_INT_TAG "channel_connectivity_state");
8484
case StatusIntProperty::kLbPolicyDrop:
8585
return TYPE_URL(TYPE_INT_TAG "lb_policy_drop");
86+
case StatusIntProperty::kStreamNetworkState:
87+
return TYPE_URL(TYPE_INT_TAG "stream_network_state");
8688
}
8789
GPR_UNREACHABLE_CODE(return "unknown");
8890
}

src/core/lib/gprpp/status_helper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ struct upb_arena;
3737
namespace grpc_core {
3838

3939
/// This enum should have the same value of grpc_error_ints
40-
// TODO(veblush): Use camel-case names once migration to absl::Status is done.
4140
enum class StatusIntProperty {
4241
/// 'errno' from the operating system
4342
kErrorNo,
@@ -72,10 +71,11 @@ enum class StatusIntProperty {
7271
ChannelConnectivityState,
7372
/// LB policy drop
7473
kLbPolicyDrop,
74+
/// stream network state
75+
kStreamNetworkState,
7576
};
7677

7778
/// This enum should have the same value of grpc_error_strs
78-
// TODO(veblush): Use camel-case names once migration to absl::Status is done.
7979
enum class StatusStrProperty {
8080
/// top-level textual description of this error
8181
kDescription,

src/core/lib/iomgr/error.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ static const char* error_int_name(grpc_error_ints key) {
252252
return "channel_connectivity_state";
253253
case GRPC_ERROR_INT_LB_POLICY_DROP:
254254
return "lb_policy_drop";
255+
case GRPC_ERROR_INT_STREAM_NETWORK_STATE:
256+
return "stream_network_state";
255257
case GRPC_ERROR_INT_MAX:
256258
GPR_UNREACHABLE_CODE(return "unknown");
257259
}

src/core/lib/iomgr/error.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ typedef enum {
9696
/// LB policy drop
9797
GRPC_ERROR_INT_LB_POLICY_DROP =
9898
static_cast<int>(grpc_core::StatusIntProperty::kLbPolicyDrop),
99+
/// stream network state
100+
GRPC_ERROR_INT_STREAM_NETWORK_STATE =
101+
static_cast<int>(grpc_core::StatusIntProperty::kStreamNetworkState),
99102

100103
/// Must always be last
101104
GRPC_ERROR_INT_MAX,

src/core/lib/transport/error_utils.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@
2727
#include "src/core/lib/iomgr/exec_ctx.h"
2828
#include "src/core/lib/transport/http2_errors.h"
2929

30+
namespace grpc_core {
31+
32+
enum class StreamNetworkState {
33+
// Stream was never sent on the wire (e.g., because the transport became
34+
// disconnected by the time the call got down to it).
35+
kNotSentOnWire,
36+
// Stream was sent on the wire but was not seen by the server application
37+
// code (e.g., client sent data but then received a GOAWAY with a lower
38+
// stream ID).
39+
kNotSeenByServer,
40+
};
41+
42+
} // namespace grpc_core
43+
3044
/// A utility function to get the status code and message to be returned
3145
/// to the application. If not set in the top-level message, looks
3246
/// through child errors until it finds the first one with these attributes.

0 commit comments

Comments
 (0)