grpc / grpc/grpc-java

Add code generation for the advanced server interface

Abierto
#339 10 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Java
Estrellas
12.1k
Forks
4k
Merge medio
2 d 17 h
PR fusionados (30 d)
37

Descripción

I asked on the mailing list (https://groups.google.com/forum/#!topic/grpc-io/1RiPC8XYP_U) whether a callback existed to notify the server that a client had disconnected so it could perform some cleanup actions. Here's the answer I received from Eric Anderson:

Because it is a unary request, there isn't a callback that notifies you of client cancellation (any error is considered a cancellation to the server). The next time you call onValue though, an exception will be thrown notifying you of the cancellation. That is enough in some scenarios.

The "advanced" interface provides such notification though. It has onHalfClose (which is when onComplete is normally called), onComplete (when the RPC gracefully completed), and onCancel (if there was an error or if the client cancelled). We don't have code generation for the advanced interface though, so you would need to implement ServerCallHandler for each method in the service, create ServerMethodDefinitions and add them to a ServerServiceDefinition, which is what you pass to the ServerBuilder's addService. That would be verbose and annoying, but simple code. It would probably make sense for you to create an issue for us to add codegen for the advanced interface.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.