question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide a decorator/utility that can send a gRPC response.

See original GitHub issue

Sometimes, 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:open
  • Created 4 years ago
  • Reactions:3
  • Comments:25 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
be-hasecommented, Jun 1, 2022

yes. ServerInteceptor is synchronous. A similar problem has been pointed out in gRPC-kotlin. https://github.com/grpc/grpc-kotlin/issues/223

2reactions
octo47commented, Nov 3, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Basics tutorial | Go - gRPC
This tutorial provides a basic Go programmer's introduction to working ... As you can see, instead of getting simple request and response objects...
Read more >
Authentication - gRPC
gRPC provides a simple authentication API based around the unified concept of Credentials objects, which can be used when creating an entire ...
Read more >
Basics tutorial | Java - gRPC
This tutorial provides a basic Java programmer's introduction to working with gRPC. By walking through this example you'll learn how to:.
Read more >
Core concepts, architecture and lifecycle - gRPC
The server can then either send back its own initial metadata (which must be sent before any response) straight away, or wait for...
Read more >
Basics tutorial | Python - gRPC
This tutorial provides a basic Python programmer's introduction to ... As you can see in the example, you specify a response-streaming ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found