Provide a decorator/utility that can send a gRPC response.
See original GitHub issueSometimes, a user wants to write an Armeria-level decorator (i.e. SimpleDecoratingHttpService) which intercepts a gRPC request and sends a pre-defined gRPC response instead of delegating to the actual GrpcService.
This can be useful when you want to send a gRPC response for authentication failure, throttled requests, etc.
We could provide some serialization utility which allows a user to serialize a single gRPC response into an HttpResponse, for example. I believe this is doable somehow by using ArmeriaMessageFramer but it would be nice if it’s simpler and more convenient.
Similarly, we might want to provide a way to deserialize a gRPC HttpResponse into a StreamMessage of gRPC messages and others, since it will be useful for writing RetryStrategy.
/cc @okue
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:25 (5 by maintainers)

Top Related StackOverflow Question
yes. ServerInteceptor is synchronous. A similar problem has been pointed out in gRPC-kotlin. https://github.com/grpc/grpc-kotlin/issues/223
I would interested in some solution as well. My case is I need async ServerInterceptor. Unfortunately ServerInterceptor is a synchronous and to make it async some significant effort required (seen various solutions around keeping queue of incoming requests and only pass them once auth is compete). Such solution is quite brittle.
On the other hand Armeria has a brilliant async infrastructure with decorators.
At the moment I test the solution where I use Armeria Authorizer to pre-auth user (i.e set AuthorizationResult in the ServiceRequestContext) and implement ServerInterceptor which will just make sure context has successful result.
Generally it works so far, unfortunately it scary to configure as you need to configure in two places: grpc and armeria.
Please, consider adding some form of async gRPC interceptors, even if they will not be gRPC compatible (as they are not anyway because of Context), but give a nice benefit over stock grpc to those who needs async interceptors.