-
Notifications
You must be signed in to change notification settings - Fork 922
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 custom json marshaller for unframed gRPC error #5555
Support custom json marshaller for unframed gRPC error #5555
Conversation
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5555 +/- ##
============================================
+ Coverage 73.95% 74.05% +0.09%
- Complexity 20115 20982 +867
============================================
Files 1730 1821 +91
Lines 74161 77352 +3191
Branches 9465 9882 +417
============================================
+ Hits 54847 57280 +2433
- Misses 14837 15421 +584
- Partials 4477 4651 +174 ☔ View full report in Codecov by Sentry. |
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandler.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandler.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorResponseType.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly minor things - thanks for your patience!
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
grpc/src/test/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilderTest.java
Outdated
Show resolved
Hide resolved
grpc/src/test/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerTest.java
Outdated
Show resolved
Hide resolved
grpc/src/test/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerTest.java
Outdated
Show resolved
Hide resolved
grpc/src/test/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerTest.java
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilder.java
Outdated
Show resolved
Hide resolved
…pcErrorHandlerBuilder.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grpc/src/test/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilderTest.java
Outdated
Show resolved
Hide resolved
grpc/src/test/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilderTest.java
Outdated
Show resolved
Hide resolved
grpc/src/test/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilderTest.java
Outdated
Show resolved
Hide resolved
grpc/src/test/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilderTest.java
Outdated
Show resolved
Hide resolved
grpc/src/test/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilderTest.java
Outdated
Show resolved
Hide resolved
…of github.com:sato9818/armeria into feature/implement-unframed-grpc-error-handler-builder
grpc/src/test/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandlerBuilderTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice and useful! Thanks, @sato9818. 🙇♂️🙇♂️
@@ -110,7 +114,8 @@ static UnframedGrpcErrorHandler of(UnframedGrpcStatusMappingFunction statusMappi | |||
* @param statusMappingFunction The function which maps the {@link Throwable} or gRPC {@link Status} code | |||
* to an {@link HttpStatus} code. | |||
*/ | |||
static UnframedGrpcErrorHandler ofJson(UnframedGrpcStatusMappingFunction statusMappingFunction) { | |||
static UnframedGrpcErrorHandler ofJson( | |||
UnframedGrpcStatusMappingFunction statusMappingFunction, MessageMarshaller jsonMarshaller) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional) This class becomes larger and more complex compared to its initial implementation. I think it's time to refactor. Are you interested in sending a follow/up PR to extract the code into TextUnframedGrpcErrorHandler
and JsonUnframedGrpcErrorHandler
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course!
/** | ||
* Constructs a {@link UnframedGrpcErrorHandler} to handle unframed gRPC errors. | ||
*/ | ||
public final class UnframedGrpcErrorHandlerBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public final class UnframedGrpcErrorHandlerBuilder { | |
@UnstableApi | |
public final class UnframedGrpcErrorHandlerBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When should we use @Unstable
generally?
I'm just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We add @UnstableApi
for new public APIs. It is best not to produce any breaking changes. However, it is difficult to make an API stable from the start. @UnstableApi
is a marker that the API can be changed in a minor update.
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorResponseType.java
Show resolved
Hide resolved
grpc/src/main/java/com/linecorp/armeria/server/grpc/UnframedGrpcErrorHandler.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM! 🙇♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
* upstream/main: Allow `{Service,Server}ErrorHandler.renderStatus()` to access `ServiceRequestContext` (line#5634) Bump com.gradle.enterprise from 3.16.2 to 3.17 (line#5559) Bump com.gradle.common-custom-user-data-gradle-plugin from 2.0 to 2.0.1 (line#5618) Add SchemeAndAuthority class which is in charge of authority normalization (line#5561) [Issue-5581] Change into transitive dependency(netty.transport.native.unix.common) (line#5623) Make @description annotation at super class/interface work (line#5562) Support `ResponseEntity` in annotated service instead of `HttpResult` (line#5586) Update public suffix list (line#5625) Wait until buffers are released in `ExceedingServiceMaxContentLengthTest.maxContentLength` (line#5600) Add the release note for 1.28.2 (line#5615) Fixed bug where a request timeout is scheduled after receiving the entire body (line#5614) Support custom json marshaller for unframed gRPC error (line#5555) Update public suffix list (line#5612)
Motivation: Refactor `UnframedGrpcErrorHandlers`. #5555 (comment) Modifications: - Create `TextUnframedGrpcErrorHandler` for a plaintext format response. - Create `JsonUnframedGrpcErrorHandler` for a JSON format response. - Create `DefaultUnframedGrpcErrorHandler` for a default error handler. Result: - Seperate `UnframedGrpcErrorHandlers` into three classes, `TextUnframedGrpcErrorHandler`, `JsonUnframedGrpcErrorHandler` and `DefaultUnframedGrpcErrorHandler`. --------- Co-authored-by: minwoox <songmw725@gmail.com> Co-authored-by: jrhee17 <guins_j@guins.org>
Motivation: - A user can't use custom JSON marshaller for unframed grpc error. Modifications: - Implement `UnframedGrpcErrorHandlerBuilder` which takes a custom json marshaller Result: - Closes line#4723. - A user can use their custom JSON marshaller for unframed grpc error.
Motivation: Refactor `UnframedGrpcErrorHandlers`. line#5555 (comment) Modifications: - Create `TextUnframedGrpcErrorHandler` for a plaintext format response. - Create `JsonUnframedGrpcErrorHandler` for a JSON format response. - Create `DefaultUnframedGrpcErrorHandler` for a default error handler. Result: - Seperate `UnframedGrpcErrorHandlers` into three classes, `TextUnframedGrpcErrorHandler`, `JsonUnframedGrpcErrorHandler` and `DefaultUnframedGrpcErrorHandler`. --------- Co-authored-by: minwoox <songmw725@gmail.com> Co-authored-by: jrhee17 <guins_j@guins.org>
Motivation:
Modifications:
UnframedGrpcErrorHandlerBuilder
which takes a custom json marshallerResult: