@@ -105,164 +105,4 @@ public void recordDisconnection(String target, String backendService, String loc
105105 ImmutableList .of (target ),
106106 ImmutableList .of (securityLevel , backendService , locality ));
107107 }
108-
109- /**
110- * Represents the reason for a subchannel failure.
111- */
112- public enum DisconnectError {
113-
114- /**
115- * Represents an HTTP/2 GOAWAY frame. The specific error code
116- * (e.g., "NO_ERROR", "PROTOCOL_ERROR") should be handled separately
117- * as it is a dynamic part of the error.
118- * See RFC 9113 for error codes: https://www.rfc-editor.org/rfc/rfc9113.html#name-error-codes
119- */
120- GOAWAY ("goaway" ),
121-
122- /**
123- * The subchannel was shut down for various reasons like parent channel shutdown,
124- * idleness, or load balancing policy changes.
125- */
126- SUBCHANNEL_SHUTDOWN ("subchannel shutdown" ),
127-
128- /**
129- * Connection was reset (e.g., ECONNRESET, WSAECONNERESET).
130- */
131- CONNECTION_RESET ("connection reset" ),
132-
133- /**
134- * Connection timed out (e.g., ETIMEDOUT, WSAETIMEDOUT), including closures
135- * from gRPC keepalives.
136- */
137- CONNECTION_TIMED_OUT ("connection timed out" ),
138-
139- /**
140- * Connection was aborted (e.g., ECONNABORTED, WSAECONNABORTED).
141- */
142- CONNECTION_ABORTED ("connection aborted" ),
143-
144- /**
145- * Any socket error not covered by other specific disconnect errors.
146- */
147- SOCKET_ERROR ("socket error" ),
148-
149- /**
150- * A catch-all for any other unclassified reason.
151- */
152- UNKNOWN ("unknown" );
153-
154- private final String errorTag ;
155-
156- /**
157- * Private constructor to associate a description with each enum constant.
158- *
159- * @param errorTag The detailed explanation of the error.
160- */
161- DisconnectError (String errorTag ) {
162- this .errorTag = errorTag ;
163- }
164-
165- /**
166- * Gets the error string suitable for use as a metric tag.
167- *
168- * <p>If the reason is {@code GOAWAY}, this method requires the specific
169- * HTTP/2 error code to create the complete tag (e.g., "goaway PROTOCOL_ERROR").
170- * For all other reasons, the parameter is ignored.</p>
171- *
172- * @param goawayErrorCode The specific HTTP/2 error code. This is only
173- * used if the reason is GOAWAY and should not be null in that case.
174- * @return The formatted error string.
175- */
176- public String getErrorString (@ Nullable String goawayErrorCode ) {
177- if (this == GOAWAY ) {
178- if (goawayErrorCode == null || goawayErrorCode .isEmpty ()) {
179- // Return the base tag if the code is missing, or consider throwing an exception
180- // throw new IllegalArgumentException("goawayErrorCode is required for GOAWAY reason.");
181- return this .errorTag ;
182- }
183- return this .errorTag + " " + goawayErrorCode ;
184- }
185- return this .errorTag ;
186- }
187- }
188-
189- /**
190- * Represents the reason for a subchannel failure.
191- */
192- public enum DisconnectError {
193-
194- /**
195- * Represents an HTTP/2 GOAWAY frame. The specific error code
196- * (e.g., "NO_ERROR", "PROTOCOL_ERROR") should be handled separately
197- * as it is a dynamic part of the error.
198- * See RFC 9113 for error codes: https://www.rfc-editor.org/rfc/rfc9113.html#name-error-codes
199- */
200- GOAWAY ("goaway" ),
201-
202- /**
203- * The subchannel was shut down for various reasons like parent channel shutdown,
204- * idleness, or load balancing policy changes.
205- */
206- SUBCHANNEL_SHUTDOWN ("subchannel shutdown" ),
207-
208- /**
209- * Connection was reset (e.g., ECONNRESET, WSAECONNERESET).
210- */
211- CONNECTION_RESET ("connection reset" ),
212-
213- /**
214- * Connection timed out (e.g., ETIMEDOUT, WSAETIMEDOUT), including closures
215- * from gRPC keepalives.
216- */
217- CONNECTION_TIMED_OUT ("connection timed out" ),
218-
219- /**
220- * Connection was aborted (e.g., ECONNABORTED, WSAECONNABORTED).
221- */
222- CONNECTION_ABORTED ("connection aborted" ),
223-
224- /**
225- * Any socket error not covered by other specific disconnect errors.
226- */
227- SOCKET_ERROR ("socket error" ),
228-
229- /**
230- * A catch-all for any other unclassified reason.
231- */
232- UNKNOWN ("unknown" );
233-
234- private final String errorTag ;
235-
236- /**
237- * Private constructor to associate a description with each enum constant.
238- *
239- * @param errorTag The detailed explanation of the error.
240- */
241- DisconnectError (String errorTag ) {
242- this .errorTag = errorTag ;
243- }
244-
245- /**
246- * Gets the error string suitable for use as a metric tag.
247- *
248- * <p>If the reason is {@code GOAWAY}, this method requires the specific
249- * HTTP/2 error code to create the complete tag (e.g., "goaway PROTOCOL_ERROR").
250- * For all other reasons, the parameter is ignored.</p>
251- *
252- * @param goawayErrorCode The specific HTTP/2 error code. This is only
253- * used if the reason is GOAWAY and should not be null in that case.
254- * @return The formatted error string.
255- */
256- public String getErrorString (@ Nullable String goawayErrorCode ) {
257- if (this == GOAWAY ) {
258- if (goawayErrorCode == null || goawayErrorCode .isEmpty ()) {
259- // Return the base tag if the code is missing, or consider throwing an exception
260- // throw new IllegalArgumentException("goawayErrorCode is required for GOAWAY reason.");
261- return this .errorTag ;
262- }
263- return this .errorTag + " " + goawayErrorCode ;
264- }
265- return this .errorTag ;
266- }
267- }
268108}
0 commit comments