Support adding gRPC interceptors using annotation '@GrpcInterceptor'
Motivation:
#5359
Adding annotations to add interceptors to gRPC services and methods.
Modifications:
- Create the
GrpcInterceptorannotation. - Update
GrpcServerBuilderto find interceptors defined by annotations on gRPC servers and methods.
Result:
- Closes #5359
The way services are added to the HandlerRegistry has changed slightly, now we are not adding the whole Service objects as an entry but rather we find all MethodDescriptors under those services and add those methods one by one as Entry objects. The reason is that we can't create a single interceptor under a single Service object that would intercept individual methods, those methods need to be added as separate entries.
It can be checked if there is any method interception annotations and if there isn't any, it can fallback to the legacy logic (add the whole Service object as an Entry).
Question Do you think adding each method as a separate Entry would create performance issues?
Also, let me know if the interceptor order looks right based on the test.
๐ Build Scanยฎ (commit: fdccead176b725c007689e1143fdb8a6392ce789)
| Job name | Status | Build Scanยฎ |
|---|---|---|
| build-windows-latest-jdk-21 | โ | https://ge.armeria.dev/s/4xyrseb4wymye |
| build-self-hosted-unsafe-jdk-8 | โ | https://ge.armeria.dev/s/sjttku4b75fwy |
| build-self-hosted-unsafe-jdk-21-snapshot-blockhound | โ (failure) | https://ge.armeria.dev/s/ibruz3okmyimq |
| build-self-hosted-unsafe-jdk-17-min-java-17-coverage | โ | https://ge.armeria.dev/s/sdoymsocgvpmc |
| build-self-hosted-unsafe-jdk-17-min-java-11 | โ | https://ge.armeria.dev/s/maoz6xuu4bxee |
| build-self-hosted-unsafe-jdk-17-leak | โ | https://ge.armeria.dev/s/pr7lq5tfweezm |
| build-self-hosted-unsafe-jdk-11 | โ | https://ge.armeria.dev/s/w22tspw5kbe6e |
| build-macos-12-jdk-21 | โ (failure) | https://ge.armeria.dev/s/yvy75by4g4qic |
Codecov Report
Attention: Patch coverage is 88.31169% with 9 lines in your changes missing coverage. Please review.
Project coverage is 74.01%. Comparing base (
14c5566) to head (78e9d53). Report is 72 commits behind head on main.
:exclamation: Current head 78e9d53 differs from pull request most recent head 89f1b76
Please upload reports for the commit 89f1b76 to get more accurate results.
Additional details and impacted files
@@ Coverage Diff @@
## main #5397 +/- ##
============================================
- Coverage 74.05% 74.01% -0.04%
+ Complexity 21253 20745 -508
============================================
Files 1850 1800 -50
Lines 78600 76488 -2112
Branches 10032 9737 -295
============================================
- Hits 58209 56615 -1594
+ Misses 15686 15263 -423
+ Partials 4705 4610 -95
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I think this PR looks good. Is there anything left for discussion or feedback, @Dogacel ?
I don't think anything left for discussion, @minwoox 's comment should be resolved now ๐ I merged latest master to double check the state of the tests.
Bump ^ ๐ Seems like this was forgotten