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

Make asynchronous interceptors easier #1619

Open
weissi opened this issue Jun 22, 2023 · 5 comments
Open

Make asynchronous interceptors easier #1619

weissi opened this issue Jun 22, 2023 · 5 comments

Comments

@weissi
Copy link
Contributor

weissi commented Jun 22, 2023

Currently, if you use a Server/ClientInterceptor you need to manually buffer if any of your processing is asynchronous. This is very error prone, hard to test and actually also causes back-pressure issues.

I think an interceptor should actually only be called once it's done processing the previously intercepted message part. Are there really many use cases where you need to see the next part before having fully processed the previous one?

Related #1618 / #1620

@Lukasa
Copy link
Collaborator

Lukasa commented Jun 23, 2023

I think it makes some sense to offer a constrained interceptor that does the buffering itself, similar to ByteToMessageDecoder. But it is useful to give access to the unvarnished stream, it grants more capabilities to the interceptors.

@FranzBusch
Copy link
Collaborator

IMO if we are going to make the interceptors fully async this problem should go away and we should just be able to forward the async sequences.

@weissi
Copy link
Contributor Author

weissi commented Jun 23, 2023

Right, if we model interceptors as async sequences this would be solved. This is very easily doable in the futures world too though, unclear if required.

@FranzBusch
Copy link
Collaborator

Right, if we model interceptors as async sequences this would be solved. This is very easily doable in the futures world too though, unclear if required.

I let @glbrntt speak to that in more detail but there are a bunch of improvements that we have discussed for the current interceptors and a new async approach would solve those. Furthermore, the SSWG is currently building out a common middleware protocol which hopefully can be used here as interceptors as well.

@glbrntt
Copy link
Collaborator

glbrntt commented Jun 23, 2023

We have some (tentative) plans to do a bunch of work on grpc-swift... part of that would be making grpc-swift 'async first' and not exposing futures in the interface (where possible). This would include interceptors because they are a particular pain point. As Franz notes, this could be using a common middleware protocol, but we'll see.

I'd rather we held off on this for now until we have a better idea of what our plans are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants