Skip to content

Conversation

jonhoo
Copy link
Collaborator

@jonhoo jonhoo commented Mar 20, 2020

ServiceExt::ready says that it produces "A future yielding the service
when it is ready to accept a request." This is not true; it does not
yield the service when it is ready, it yields unit. This makes it
impossible to chain service ready with service call, which is sad.

This PR adds ready_and, which does what ready promised. It also
deprecates ready with the intention that we remove ready in a future
version, and make the strictly more general ready_and take its place.
We can't do it now since it's not a backwards-compatible change even
though it probably wouldn't break any code.

The PR also updates the docs so that they reflect the observed behavior.

`ServiceExt::ready` says that it produces "A future yielding the service
when it is ready to accept a request." This is not true; it does _not_
yield the service when it is ready, it yields unit. This makes it
impossible to chain service ready with service call, which is sad.

This PR adds `ready_and`, which does what `ready` promised. It also
deprecates `ready` with the intention that we remove `ready` in a future
version, and make the strictly more general `ready_and` take its place.
We can't do it now since it's not a backwards-compatible change even
though it _probably_ wouldn't break any code.

The PR also updates the docs so that they reflect the observed behavior.
@jonhoo jonhoo requested a review from LucioFranco March 20, 2020 20:30
where
T: Service<Request>,
{
#[allow(missing_docs)]
Copy link
Member

Choose a reason for hiding this comment

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

should we just add docs now :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I always found documentation on new super weird since it becomes so trivial (for simple cases like this). I guess I could add something, but my inclination is to leave it 😅

pub struct Ready<'a, T, Request> {
inner: &'a mut T,
/// `ReadyOneshot` values are produced by `ServiceExt::ready_oneshot`.
pub struct ReadyOneshot<T, Request> {
Copy link
Member

Choose a reason for hiding this comment

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

Do we want a manual clone impl if T is clone?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My first instinct says no — it should be rare that you'd want to clone a ReadyOneshot as opposed to cloning the underlying Service. If you did, that's probably not what you meant to do.

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

Left a few comments, nothing blocking :)

@jonhoo jonhoo merged commit 52fde97 into master Mar 23, 2020
@jonhoo jonhoo deleted the ready-and branch March 23, 2020 16:49
hawkw pushed a commit that referenced this pull request Feb 25, 2021
This PR renames: 

- `ServiceExt::ready_and` to `ServiceExt::ready`
- the `ReadyAnd` future to `Ready`
- the associated documentation to refer to `ServiceExt::ready`
  and `ReadyAnd`.

This PR deprecates:

- the `ServiceExt::ready_and` method
- the `ReadyAnd` future

These can be removed in Tower 0.5.

My recollection of the original conversation surrounding the
introduction of the `ServiceExt::ready_and` combinator in
#427 was that it was meant to be a
temporary workaround for the unchainable `ServiceExt::ready` combinator
until the next breaking release of the Tower crate. The unchainable
`ServiceExt::ready` combinator was removed, but `ServiceExt::ready_and`
was not renamed. I believe, but am not 100% sure, that this was an
oversight.
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