Skip to content
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

Refactor server calls to implement ServerCallHandler #79

Open
marcoferrer opened this issue Sep 9, 2019 · 0 comments
Open

Refactor server calls to implement ServerCallHandler #79

marcoferrer opened this issue Sep 9, 2019 · 0 comments
Labels
enhancement New feature or request grpc-coroutines

Comments

@marcoferrer
Copy link
Owner

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

@marcoferrer marcoferrer added enhancement New feature or request grpc-coroutines labels Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request grpc-coroutines
Projects
None yet
Development

No branches or pull requests

1 participant