Currently server implementations use server handler builder to process incoming calls using the existing stream observer api. This requires a lot of adapter code just to map coroutine behavior to the existing stream observer call back.
It should be possible to implement ServerCallHandler and emit its usage in the generated code. This gives us the ability to not only improve performance but map the coroutine apis closer to the call level.
At the moment it is difficult to expand the kroto API. With access to the call, we could potentially allow users to pass execution parameters via a call wrapper type. This would allow the customization of the following:
Server method CoroutineStart
Initial coroutineContext
Channel buffer size for streaming APIs
(Possibly?) Custom Exception handlers
Call wrapper example:
abstract class ServerCallCoroutine<ReqT,RespT>(
delegate: ServerCall<ReqT,RespT>
) : SimpleForwardingServerCall<ReqT,RespT>(delegate){
open val initialContext: CoroutineContext = EmptyCoroutineContext
open val coroutineStart: CoroutineStart = CoroutineStart.ATOMIC
open val requestChannelBufferSize: Int = Channel.BUFFER
}
The kroto implementation of ServerCallHandler would be able to check for this type explicitly during method invocation and use the parameters provided
Currently server implementations use server handler builder to process incoming calls using the existing stream observer api. This requires a lot of adapter code just to map coroutine behavior to the existing stream observer call back.
It should be possible to implement
ServerCallHandler
and emit its usage in the generated code. This gives us the ability to not only improve performance but map the coroutine apis closer to the call level.At the moment it is difficult to expand the kroto API. With access to the call, we could potentially allow users to pass execution parameters via a call wrapper type. This would allow the customization of the following:
CoroutineStart
coroutineContext
Call wrapper example:
The kroto implementation of
ServerCallHandler
would be able to check for this type explicitly during method invocation and use the parameters provided