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

InFlightLimit middleware #49

Merged
merged 4 commits into from
Feb 20, 2018
Merged

InFlightLimit middleware #49

merged 4 commits into from
Feb 20, 2018

Conversation

carllerche
Copy link
Member

@carllerche carllerche commented Feb 19, 2018

This PR adds an InFlightLimit middleware that enforces a max number if in-flight requests for the inner service as well as all clones.

This middleware works for both Service and ReadyService.

@carllerche
Copy link
Member Author

The implementation should be ready to go. There is one remaining question around trait implementations.

InFlightLimit applies both to Service and ReadyService. Currently, InFlightLimit<T: ReadyService> implements ReadyService itself. However, it could also implement Service directly because the limiting factor is itself the poll_ready implementation.

The problem is, coherence doesn't let us implement both Service AND ReadyService for InFlightLimit<T: ReadyService> if there also is an implementation for T: Service...

One solution would be to have separate middleware for taking a T: ReadyService and lifting it to a Service by bounding the max in-flight.

@carllerche
Copy link
Member Author

Great, I'm going to merge the PR as is. Handling the issue discussed in the above comment depends on the fate of ReadyService (#50).

@carllerche carllerche merged commit 41c54b2 into master Feb 20, 2018
@carllerche carllerche deleted the in-flight-limit branch April 30, 2018 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants