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

docs: provide an example to explain the cloning inner services #762

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shengsheng
Copy link

Provide the example "ConcurrencyLimit" to explain why "Even though the original service is ready, the clone might not be".
https://docs.rs/tower/latest/tower/limit/struct.ConcurrencyLimit.html#impl-Clone

@@ -236,7 +236,10 @@ use std::task::{Context, Poll};
///
/// Services are permitted to panic if `call` is invoked without obtaining `Poll::Ready(Ok(()))`
/// from `poll_ready`. You should therefore be careful when cloning services for example to move
/// them into boxed futures. Even though the original service is ready, the clone might not be.
/// them into boxed futures. Even though the original service is ready, the clone might not be,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how ConcurrencyLimit exemplifies what this docs section is trying to convey. If you're referring to the fact that cloning an inner ConcurrencyLimit service resets the permit to unacquired and that poll_ready acquires it, that will only be understood by readers who have read ConcurrencyLimit's source code.

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