envoyproxy / java-control-plane

Java implementation of an Envoy gRPC control plane
Apache License 2.0
293 stars 136 forks source link

server: allow throwing checked exception from stream callbacks #257

Closed shulin-sq closed 1 year ago

shulin-sq commented 1 year ago

This PR introduces throwing a checked exception from stream callbacks, and catching them to trigger clean up tasks such as calling onStreamClose(WithError)

This follows a similar pattern to the go-control-plane where certain callbacks can return errors https://github.com/envoyproxy/go-control-plane/blob/bf9fc1db9d0fefb8df1291fc4638b0f2d7f39a7e/pkg/server/v3/server.go#L70-L81

And a defer statement calls OnStreamClosed https://github.com/envoyproxy/go-control-plane/blob/bf9fc1db9d0fefb8df1291fc4638b0f2d7f39a7e/pkg/server/sotw/v3/server.go#L93-L98

Signed-off-by: Shulin Jia shulin@squareup.com

codecov-commenter commented 1 year ago

Codecov Report

Merging #257 (813992d) into main (90a3ccd) will decrease coverage by 0.10%. The diff coverage is 83.33%.

@@             Coverage Diff              @@
##               main     #257      +/-   ##
============================================
- Coverage     86.24%   86.13%   -0.11%     
- Complexity      351      352       +1     
============================================
  Files            41       41              
  Lines          1141     1154      +13     
  Branches         93       95       +2     
============================================
+ Hits            984      994      +10     
- Misses          112      115       +3     
  Partials         45       45              
Impacted Files Coverage Δ
...ne/server/DeltaDiscoveryRequestStreamObserver.java 72.81% <0.00%> (ø)
.../controlplane/server/DiscoveryServerCallbacks.java 40.00% <ø> (ø)
...ontrolplane/server/exception/RequestException.java 100.00% <ø> (ø)
...nvoyproxy/controlplane/server/DiscoveryServer.java 90.90% <78.57%> (-5.97%) :arrow_down:
...lane/server/AdsDiscoveryRequestStreamObserver.java 100.00% <100.00%> (ø)
...olplane/server/DiscoveryRequestStreamObserver.java 85.00% <100.00%> (ø)
...oyproxy/controlplane/server/V3DiscoveryServer.java 93.75% <100.00%> (+0.20%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.