-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for custom status codes #515
Comments
Status is for a canonical status used by all gRPC servers and will only rarely be added to. I think you saw the comment "If new codes are added over time they must choose a numerical value that does not collide with any previously used value." This comment is not referring to applications adding codes, but gRPC as a whole adding new codes. The current set of codes should be able to appropriately describe almost any application status in a generic way. For custom status information, use Metadata. |
I assume a custom ServerInterceptor is required to set Metadata on a response. For convenience, would it make sense to allow Metadata to be attached to Status{Runtime}Exception? |
We could have Status-specific metadata attached to the Status, but I think at least @louiscryan doesn't think that gains too much. However, soon we hope to have a Context API (#262) that would be available via ThreadLocal and could be used by a ServerInterceptor to propagate information to the application. |
io.grpc.Status seems to be restricted to the built-in status codes provided, although javadoc suggests that new status codes can be used as long as they are not conflicting. Adding a factory method such as "Status.forCode" should be possible although this would require that the status code type be changed from an enum to integer constant. This may be a small price to pay for the added flexibility.
The text was updated successfully, but these errors were encountered: