-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
loadbalancer: Add the ErrorClass enum and use it in RequestTracker (#…
…2808) Motivation: RequestTracker has three observer methods: `onSuccess`, `onCancel`, and `onError`. onCancel is really a special case of `onError` but it can be helpful to distinguish them at times which leads to the more general problem: it is often helpful to know what kind of error it was so we can establish the origin. Modifications: - Add the `ErrorClass` enum for classifying `RequestTracker` errors. - Consolidate the `onCancel` method into the `onError` method by having a `CANCELLED` variant of the `ErrorClass` enum. Result: Less methods and more information about the origin of errors.
- Loading branch information
1 parent
904ed6f
commit 00e740c
Showing
6 changed files
with
79 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
servicetalk-loadbalancer/src/main/java/io/servicetalk/loadbalancer/ErrorClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright © 2024 Apple Inc. and the ServiceTalk project authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.servicetalk.loadbalancer; | ||
|
||
/** | ||
* Enumeration of the main failure classes. | ||
*/ | ||
enum ErrorClass { | ||
|
||
/** | ||
* Failures related to locally enforced timeouts that prevent session establishment with the peer. | ||
*/ | ||
LOCAL_ORIGIN_TIMEOUT(true), | ||
/** | ||
* Failures related to connection establishment. | ||
*/ | ||
LOCAL_ORIGIN_CONNECT_FAILED(true), | ||
|
||
/** | ||
* Failures related to locally enforced timeouts waiting for responses from the peer. | ||
*/ | ||
EXT_ORIGIN_TIMEOUT(false), | ||
|
||
/** | ||
* Failures returned from the remote peer. This will be things like 5xx responses. | ||
*/ | ||
EXT_ORIGIN_REQUEST_FAILED(false), | ||
|
||
/** | ||
* Failure due to cancellation. | ||
*/ | ||
CANCELLED(true); | ||
|
||
private final boolean isLocal; | ||
ErrorClass(boolean isLocal) { | ||
this.isLocal = isLocal; | ||
} | ||
|
||
public boolean isLocal() { | ||
return isLocal; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters