marcoferrer / kroto-plus

gRPC Kotlin Coroutines, Protobuf DSL, Scripting for Protoc
Apache License 2.0
493 stars 28 forks source link

Outbound channel close error is propagated to stream #95

Closed marcoferrer closed 4 years ago

marcoferrer commented 4 years ago

This PR resolves issue #93

codecov-io commented 4 years ago

Codecov Report

Merging #95 into master will increase coverage by 0.91%. The diff coverage is 85.18%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #95      +/-   ##
============================================
+ Coverage     85.62%   86.53%   +0.91%     
  Complexity       19       19              
============================================
  Files            15       15              
  Lines           306      312       +6     
  Branches         49       53       +4     
============================================
+ Hits            262      270       +8     
  Misses           15       15              
+ Partials         29       27       -2
Impacted Files Coverage Δ Complexity Δ
...oferrer/krotoplus/coroutines/client/ClientCalls.kt 87.17% <ø> (ø) 0 <0> (ø) :arrow_down:
...utines/call/FlowControlledInboundStreamObserver.kt 82.6% <ø> (+3.44%) 0 <0> (ø) :arrow_down:
.../marcoferrer/krotoplus/coroutines/call/CallExts.kt 84.84% <83.33%> (-3.04%) 0 <0> (ø)
...rcoferrer/krotoplus/coroutines/call/FlowControl.kt 89.18% <86.66%> (+2.52%) 0 <0> (ø) :arrow_down:
...s/coroutines/client/ClientResponseStreamChannel.kt 100% <0%> (+14.28%) 9% <0%> (ø) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9e81e7f...c053690. Read the comment docs.

marcoferrer commented 4 years ago

I still need to add notes for the reason behind closing outbound channels with an error before cancelling it in the client channel impls. If we close a channel with our server error before cancelling it then we can ensure that any user code that is attempting to send on the outbound channel will throw the server exception. Cancel is just a means to free up the outbound message handler so that our coroutine scope can complete.

I also still need to add tests exercising this use case. Client Tests: Client Streaming, BidiStreaming Server Tests: Server Streaming, BidiStreaming