-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[server] Rewrite gRPC read service to bridge gap with Netty-based HTT…
…P server
- Loading branch information
1 parent
a782eee
commit 2a298ff
Showing
47 changed files
with
1,493 additions
and
1,176 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
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
49 changes: 35 additions & 14 deletions
49
...al/venice-common/src/main/java/com/linkedin/venice/response/VeniceReadResponseStatus.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 |
---|---|---|
@@ -1,19 +1,40 @@ | ||
package com.linkedin.venice.response; | ||
|
||
import io.netty.handler.codec.http.HttpResponseStatus; | ||
|
||
|
||
/** | ||
* Enumeration of response status codes for Venice read requests. | ||
* <p> | ||
* **Positive values** correspond to standard HTTP status codes and can be used directly in HTTP responses. | ||
* **Negative values** represent custom Venice-specific error codes. | ||
* <p> | ||
* For example, a status code of `200` indicates a successful read, while a status code of `-100` might indicate a specific Venice-related error. | ||
* Defines response status codes for Venice read requests. This wrapper around {@link HttpResponseStatus} allows | ||
* for the inclusion of custom status codes that extend beyond the standard HTTP status codes. | ||
*/ | ||
public class VeniceReadResponseStatus { | ||
public static final int KEY_NOT_FOUND = -420; | ||
|
||
public static final int OK = 200; | ||
public static final int BAD_REQUEST = 400; | ||
public static final int INTERNAL_ERROR = 500; | ||
public static final int TOO_MANY_REQUESTS = 429; | ||
public static final int SERVICE_UNAVAILABLE = 503; | ||
public enum VeniceReadResponseStatus { | ||
KEY_NOT_FOUND(HttpResponseStatus.NOT_FOUND), OK(HttpResponseStatus.OK), BAD_REQUEST(HttpResponseStatus.BAD_REQUEST), | ||
FORBIDDEN(HttpResponseStatus.FORBIDDEN), METHOD_NOT_ALLOWED(HttpResponseStatus.METHOD_NOT_ALLOWED), | ||
REQUEST_TIMEOUT(HttpResponseStatus.REQUEST_TIMEOUT), TOO_MANY_REQUESTS(HttpResponseStatus.TOO_MANY_REQUESTS), | ||
INTERNAL_SERVER_ERROR(HttpResponseStatus.INTERNAL_SERVER_ERROR), | ||
SERVICE_UNAVAILABLE(HttpResponseStatus.SERVICE_UNAVAILABLE), | ||
MISROUTED_STORE_VERSION(new HttpResponseStatus(570, "Misrouted request")); | ||
|
||
private final HttpResponseStatus httpResponseStatus; | ||
|
||
VeniceReadResponseStatus(HttpResponseStatus httpResponseStatus) { | ||
this.httpResponseStatus = httpResponseStatus; | ||
} | ||
|
||
public HttpResponseStatus getHttpResponseStatus() { | ||
return httpResponseStatus; | ||
} | ||
|
||
public int getCode() { | ||
return httpResponseStatus.code(); | ||
} | ||
|
||
public static VeniceReadResponseStatus fromCode(int code) { | ||
for (VeniceReadResponseStatus status: values()) { | ||
if (status.getCode() == code) { | ||
return status; | ||
} | ||
} | ||
throw new IllegalArgumentException("Unknown status venice read response status code: " + code); | ||
} | ||
} |
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
Oops, something went wrong.