Skip to content

How to know the response had sent finished ? #3321

Answered by jplatte
ideadawn asked this question in Q&A
Discussion options

You must be logged in to vote

Okay, so you want to limit the number of concurrent requests to a specific route that your service allows? Where are these apply_permit() / back_permit() methods coming from? The fact that the former is not async suggest that this limit_pool is not something you should be using in an async context.

This is application code, right? You could probably implement http_body::Body for a wrapper type that delegates all the methods to the inner type (using pin projection), and use Pinned Drop to give back the permit. Would have to spawn a tokio task for that last bit, if it can't be made non-async.

If that's all still too abstract, I can try to find some time to write up a code snippet.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ideadawn
Comment options

@jplatte
Comment options

Answer selected by ideadawn
@ideadawn
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants