541 Commits

Author SHA1 Message Date
Jonas Platte
3f31ffd2cf
chore: Use doc_auto_cfg (#693)
… so extra doc(cfg) attributes aren't needed in most places.
2022-09-25 16:03:54 +02:00
Daniel Cormier
c5632a26aa
docs(tower): moved docs from private tower::util::boxed module (#684)
Now they're on the public `BoxService` struct that referenced them.

Fixes #683.
2022-09-13 16:24:38 +00:00
Daniel Sedlak
4362dfc70c
retry: Extend Policy trait documentation (#690) 2022-09-12 11:33:20 -04:00
Lucio Franco
b12f14861f
retry: Add generic backoff utilities (#685)
This adds a new `Backoff` trait and a `ExponentialBackoff`
implementation borrwoed from `linkerd2-proxy`. This provides the initial
building blocks for a more fully batteries included retry policy.
2022-08-30 13:59:17 -04:00
Andrew Banchich
b6b0f27197
Remove lspower due to deprecation (#688) 2022-08-30 11:58:36 -04:00
Lucio Franco
e0558266a3
util: Add rng utilities (#686)
This adds new PRNG utilities that only use libstd and not the external
`rand` crate. This change's motivation are that in tower middleware that
need PRNG don't need the complexity and vast utilities of the `rand`
crate.

This adds a `Rng` trait which abstracts the simple PRNG features tower
needs. This also provides a `HasherRng` which uses the `RandomState`
type from libstd to generate random `u64` values. In addition, there is
an internal only `sample_inplace` which is used within the balance p2c
middleware to randomly pick a ready service. This implementation is
crate private since its quite specific to the balance implementation.

The goal of this in addition to the balance middlware getting `rand`
removed is for the upcoming `Retry` changes. The `next_f64` will be used
in the jitter portion of the backoff utilities in #685.

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2022-08-25 13:06:24 -04:00
Lucio Franco
aec7b8f417
retry: Change Policy to accept &mut self (#681)
This changes the `Policy` trait in the `retry` layer to accept `&mut
self` instead of `&self` and changes the output type of the returned
future to `()`. The motivation for this change is to simplify
the trait a bit. By the trait methods having mutable references it means
that for each retry request session you can mutate the local policy.
This is because the policy is cloned for each individual request that
arrives into the retry middleware. In addition, this allows the `Policy`
trait to be object safe.
2022-08-23 14:30:09 -04:00
Folyd
6d34340f1e
chore: fix Service doc links in tower-layer (#579)
Co-authored-by: Lucio Franco <luciofranco14@gmail.com>
2022-08-15 13:13:11 -04:00
Folyd
06a0e597e5
docs: improve docs of retry budget (#613)
Co-authored-by: Oliver Gould <ver@buoyant.io>
Co-authored-by: Lucio Franco <luciofranco14@gmail.com>
2022-08-11 11:06:03 -04:00
Bryant Luk
8805309486
service: Call inner.poll_ready() in docs when cloning inner (#679)
- The documentation should call self.inner.poll_ready() in the
  Wrapper::poll_ready() call to emphasize that self.inner may only be
  ready on the original instance and not a clone of inner.
2022-08-03 09:56:39 -07:00
Russell Cohen
19c1a1dbb8
retry: improve flexiblity of retry policy (#584)
* improve flexiblity of retry policy

retry::Policy is an effective way to expressing retries, however, there two use cases that
as it stands today, cannot be expressed:
- Altering the final response (eg. to record the fact that you ran out of retries)
- Altering the request (eg. to set a header to the server indicating that this request is a retry)

(Technically the second is possible with `clone_request`, but it's a little unclear _which_ request would actually get sent).

This change implements what I think is pretty close to the minimal update to make this possible, namely, `req`
and `Res` both become mutable references. This enables policies to mutate them during execution & enables both of the
use cases above without complicating the "simple path" callers who don't need this behavior.

**This is a breaking change.** However, the fixes are only a couple of `&mut` and potentially a call to `as_ref()`.

* Update changelog

* doc updates

- Wrap docs to 80 characters
- Small doc tweaks / rewrites to clarify & remove `you`

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Co-authored-by: Lucio Franco <luciofranco14@gmail.com>
2022-08-01 13:24:34 -04:00
Eliza Weisman
ee826286fd
chore: allow publishing releases from version branches (#674) 2022-06-17 13:41:20 -07:00
Oliver Gould
edd922d6d0
ready-cache: Ensure cancelation can be observed (#668)
`tokio::task` enforces a cooperative scheduling regime that can cause
`oneshot::Receiver::poll` to return pending after the sender has sent an
update. `ReadyCache` uses a oneshot to notify pending services that they
should not become ready. When a cancelation is not observed, the ready
cache return service instances that should have been canceled, which
breaks assumptions and causes an invalid state.

This branch replaces the use of `tokio::sync::oneshot` for canceling 
pending futures with a custom cancelation handle using an `AtomicBool`
and `futures::task::AtomicWaker`. This ensures that canceled `Pending`
services are always woken even when the task's budget is exceeded.
Additionally, cancelation status is now always known to the `Pending`
future, by checking the `AtomicBool` immediately on polls, even in cases
where the canceled `Pending` future was woken by the inner `Service`
becoming ready, rather than by the cancelation.

Fixes #415

Signed-off-by: Oliver Gould <ver@buoyant.io>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2022-06-17 12:06:35 -07:00
Eliza Weisman
22b6fc743b
ci: run MSRV checks with minimal dep versions (#670)
In many cases, new releases of a dependency can break compatibility with
Tower's minimum supported Rust version (MSRV). It shouldn't be necessary
for Tower to bump its MSRV when a dependency does, as users on older
Rust versions should be able to depend on older versions of that crate.
Instead, we should probably just run our MSRV checks with minimal
dependency versions.

This branch changes Tower's CI jobs to do that. It was also necessary to 
make some changes to the `Cargo.toml` to actually fix the build with
minimal dependency versions.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2022-06-17 11:23:32 -07:00
Eliza Weisman
45a13b128d
ready_cache: just use pin_project for Pending (#667)
This gets rid of the `Unpin` impl with the weird comment on it.

Alternatively, we could just put a `S: Unpin` bound on `Pending`, but
this changes the public API to require that the service type is `Unpin`.
In practice, it will be, but we could also just avoid the trait bound.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2022-06-17 09:15:23 -07:00
Matt Klein
3c170aaf19
load_shed: make constructor for Overloaded error public (#661)
This allows for mocking. This also matches what is done for
the timeout Elapsed error.

Signed-off-by: Matt Klein <mklein@lyft.com>
2022-06-13 11:25:11 -07:00
Matt Klein
8b522920f8
service: clarify docs around shared resource consumption in poll_ready() (#662)
Signed-off-by: Matt Klein <mklein@lyft.com>
2022-06-10 10:52:39 -07:00
Noah Kennedy
5064987ffe
log: don't enable this feature by default (#660)
Unfortunately, tracing/log is a non-additive feature (https://github.com/tokio-rs/tracing/issues/1793), so enabling it is a bit radioactive.
2022-04-14 09:25:42 +02:00
Bruno
34d6e7befa
fix: broken Service link (#659) 2022-04-07 13:33:15 -04:00
Eliza Weisman
71292ee683
balance: remove Pool (#658)
Per #456, there are a number of issues with the `balance::Pool` API that
limit its usability, and it isn't widely used. In the discussion on that
issue, we agreed that it should probably just be removed in 0.5 --- it
can be replaced with something more useful later.

This branch removes `balance::Pool`.

CLoses #456.
2022-03-31 11:09:04 -07:00
Leonardo Yvens
cc9e5bea6f
util: Fix call_all hang when stream is pending (#656)
Currently `call_all` will hang in a busy loop if called when the input
stream is pending.
2022-03-29 12:25:51 -07:00
Eliza Weisman
9f86b8f3d8
buffer: change Buffer to be generic over inner service's Future (#654)
* buffer: change `Buffer` to be generic over inner service's `Future`

This commit changes the `Buffer` service to be generic over the inner
service's `Future` type, rather than over the `Service` type itself. The
`Worker` type is still generic over the inner `Service` (and, it must
be, as it stores an instance of that service). This should reduce type
complexity of buffers a bit, as they will erase nested service types.

Unfortunately, `Buffer` is still generic over the inner service's
`Future`, which may also be nested, but it is likely to be less complex
than the `Service`. It would be nice if we could erase the `Future` type
as well, but I don't believe this is possible without either boxing the
futures or changing them to always be spawned on a background task,
neither of which seems desirable here.

Closes #641

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2022-03-29 10:41:19 -07:00
Eliza Weisman
e4e440906d
util: remove deprecated ServiceExt::ready_and (#652)
These were deprecated in #567. In 0.5, we can just remove them
entirely.

Closes #568

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2022-03-11 09:51:00 -08:00
Leonardo Yvens
d8c73fcb33
util: Unecessary bound in ServiceExt::call_all (#651) 2022-03-10 12:53:08 +01:00
Leonardo Yvens
04f0bd0cc3
util: Change CallAll error type to Svc::Error (#649) 2022-03-09 21:17:31 +01:00
Folyd
4bcfaeb33e
chore: replace Never with Infallible (#612)
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2022-03-08 09:13:16 -08:00
Eliza Weisman
0e907963c3
rewrite buffer to use bounded MPSC (#635)
* rewrite `buffer` to use bounded MPSC

## Motivation

Currently, `tower::buffer` uses `tokio::sync::mpsc`'s _unbounded_
channel plus a `tokio::sync::Semaphore`, in order to re-implement a
bounded channel. This was necessary because when this code was updated
to the latest version of `tokio`, there was no way to reserve a
non-borrowed send permit from a `Sender`. Thus, it was necessary to use
the `Semaphore` for the future that is polled in `poll_ready` to acquire
send capacity, since a `Permit` from the `Sender` could not be stored in
the struct until it's consumed in `call`.

This code is Not Ideal. Reimplementing the bounded channel makes the
implementation more complicated, and means that there is a bunch of
extra stuff we have to do to e.g. propagate cancellations/service errors
to tasks waiting on `poll_ready`. The bounded MPSC would solve most of
this for us. It might also be a bit more efficient, since we would only
have a single reference-counted heap allocation (the `Sender`), rather
than two (the `Sender` _and_ the `Arc<Semaphore>`).

in `tokio-util` v0.7, the semantics of `PollSender` was changed to have
a `poll_reserve` rather than `poll_send_done`, which is the required
behavior for `Buffer`. Therefore, we can now just use the
`tokio_util::sync::PollSender` type, and the buffer implementation is
now much simpler.

## Solution

This branch changes the buffer to use only a single bounded MPSC via
`PolLSender`, rather than an unbounded MPSC and a semaphore. The bounded
MPSC internally manages its semaphore, so we can now remove a lot of
complexity in the current implementation.

I had to change some of the integration tests slightly as part of this
change. This is because the buffer implementation using semaphore
permits is _very subtly_ different from one using a bounded channel. In
the `Semaphore`-based implementation, a semaphore permit is stored in
the `Message` struct sent over the channel. This is so that the capacity
is used as long as the message is in flight. However, when the worker
task is processing a message that's been recieved from the channel, the
permit is still not dropped. Essentially, the one message actively held
by the worker task _also_ occupies one "slot" of capacity, so the actual
channel capacity is one less than the value passed to the constructor,
_once the first request has been sent to the worker_. The bounded MPSC
changed this behavior so that capacity is only occupied while a request
is actually in the channel, which broke some tests that relied on the
old (and technically wrong) behavior.

## Notes

There is one sort of significant issue with this change, which is that
it unfortunately requires adding `Send` and `'static` bounds to the
`T::Future` and `Request` types. This is because they occur within the
`Message` type that's sent over the channel, and a MPSC's
`OwnedPermit<T>` for a message of type `T` is only `Send` or `'static`
when `T` is. For `PollSender` to be `Send` + `Sync`, the
`ReusableBoxFuture` that it uses internally requires the future be `Send
+ 'static`, which it is not when `OwnedPermit` isn't.

I don't believe that it's actually _necessary_ for the `OwnedPermit<T>`
type to require `T: Send` in order to be `Send`, or `T: 'static` in
order to be valid for the `'static` lifetime. An `OwnedPermit` never
actually contains an instance of type `T`, it just represents the
_capacity_ to send that type to the channel. The channel itself will
actually contain the values of type `T`. Therefore, it's possible this
could be changed upstream in Tokio, although I haven't looked into it
yet.

This is, however, a breaking change.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2022-02-25 17:04:21 +00:00
Oliver Gould
f0e999521d
spawn-ready: Remove useless MakeSpawnReady type (#536)
The `spawn_ready` module has two notable (public API) problems:

1. `MakeSpawnReady` is useless, as it doesn't use the target type in any
   novel way. It's nothing more than a `MapResponse`.
2. The `SpawnReadyLayer` type produces a `MakeSpawnReady` (which is, as
   mentioned, useless).

This change removes the `spawn_ready::make` module and modifies
`SpawnReadyLayer` to produce `SpawnReady` instances directly.

---

This is unfortunately a breaking change. However, the current state of
`SpawnReadyLayer` is so convoluted that I can't imagine anyone is
actually using it... If the breakage is untenable, I can revert the
module changes and include only the `JoinHandle` change.
2022-02-17 20:19:58 +00:00
David Pedersen
522687c2cd
util: rework Either (#637)
In practice I've found `Either` be hard to use since it changes the
error type to `BoxError`. That means if you combine two infallible
services you get a service that, to the type system, is fallible. That
doesn't work well with [axum's error
handling](https://docs.rs/axum/latest/axum/error_handling/index.html)
model which requires all services to be infallible and thus always
return a response. So you end up having to add boilerplate just to
please the type system.

Additionally, the fact that `Either` implements `Future` also means we
cannot fully remove the dependency on `pin-project` since
`pin-project-lite` doesn't support tuple enum variants, only named
fields.

This PR reworks `Either` to address these:

- It now requires the two services to have the same error type so no
  type information is lost. I did consider doing something like `where
  B::Error: From<A::Error>` but I hope this simpler model will lead to
  better compiler errors.
- Changes the response future to be a struct with a private enum using
  `pin-project-lite`
- Removes the `Future` impl so we can remove the dependency on
  `pin-project`

Goes without saying that this is a breaking change so we have to wait
until tower 0.5 to ship this.

cc @jplatte

Fixes #594
Fixes #550
2022-02-17 20:09:44 +00:00
Grachev Mikhail
eee7d24e3a
tower: fix docs typo (#646) 2022-02-17 19:31:52 +00:00
Eliza Weisman
12a06035eb
chore: prepare to release tower v0.4.12 (#642)
* chore: prepare to release v0.4.12

# 0.4.12 (February 16, 2022)

### Fixed

- **hedge**, **load**, **retry**: Fix use of `Instant` operations that
  can panic on platforms where `Instant` is not monotonic ([#633])
- Disable `attributes` feature on `tracing` dependency ([#623])
- Remove unused dependencies and dependency features with some feature
  combinations ([#603], [#602])
- **docs**: Fix a typo in the RustDoc for `Buffer` ([#622])

### Changed

- Updated minimum supported Rust version (MSRV) to 1.49.0.
- **hedge**: Updated `hdrhistogram` dependency to v7.0 ([#602])
- Updated `tokio-util` dependency to v0.7 ([#638])

[#633]: https://github.com/tower-rs/tower/pull/633
[#623]: https://github.com/tower-rs/tower/pull/623
[#603]: https://github.com/tower-rs/tower/pull/603
[#602]: https://github.com/tower-rs/tower/pull/602
[#622]: https://github.com/tower-rs/tower/pull/622
[#638]: https://github.com/tower-rs/tower/pull/638

* add msrv
tower-0.4.12
2022-02-16 22:42:08 +00:00
Eliza Weisman
5e280fedca
ci: fix wrong tag regex for tower (#644)
In #643, I accidentally included a `v` before the version number in the
regex for matching release tags for the `tower` crate, but not for
`tower-whatever` crates. All previous release tags on this repo don't
use a `v`, so adding it was a mistake. This branch removes it.
2022-02-16 22:07:08 +00:00
Eliza Weisman
9c184d81bc
chore: bump MSRV to 1.49.0 (#645)
`tower` builds are now failing on CI because Tokio v1.17.0 bumped MSRV
to 1.49.0. This branch updates `tower`'s MSRV to 1.49.0 to track Tokio's
MSRV. I also added nicer documentation of the MSRV based on Tokio's, and
added the `rust-version` Cargo metadata to the `tower` crate's
`Cargo.toml`.

Note that `tower-service` and `tower-layer` can technically continue to
support much earlier Rust versions than `tower` can, since they don't
depend on external crates and are very small. We could consider testing
separate, older MSRVs on CI for those crates individually. I didn't do
that in this PR, though, because I wasn't sure if this was worth the
effort and I just wanted to get CI passing again.
2022-02-16 13:14:05 -08:00
Eliza Weisman
7b6587e412
ci: automatically publish release notes to GitHub Releases (#643)
This branch adds a GitHub Actions workflow to automatically publish
release notes to GitHub Releases when a tag is pushed on the `master`
branch that corresponds to a release.

The release notes are parsed from the changelog using
taiki-e/create-release-action. The workflow will only run when a tag
matching `tower-[0-9].+` or `tower-[a-z]+-[0-9].+` is pushed to the
`master` branch on the origin (`tower-rs/tower`) repo.
2022-02-16 20:20:29 +01:00
Eliza Weisman
386de64ab4
tower: update tokio-util to v0.7 (#638)
This PR updates `tokio-util` to v0.7.

It also updates the minimum `tokio` dependency to v1.6.0.
This is because `tokio-util` requires at least `tokio` v1.6.0 for
`mpsc::Sender::reserve_owned`, but it only specifies a minimum version
of v1.0.0. This is incorrect and should be considered an upstream bug,
but updating our tokio dep fixes this, so that should at least unbreak
`tower`'s build for now.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2022-02-11 11:29:57 -08:00
Eliza Weisman
db43c07e96
tower: fix annoying clippy lints (#639)
This fixes a bunch of minor clippy lints. None of them were particularly
major, but I was getting tired of the warnings showing up in vscode.

The one lint that had to be ignored rather than fixed is the
`clippy::bool_assert_comparison` lint, which triggers on the
`tower_test::assert_request_eq!` macro. The lint triggers when writing
code like `assert_eq!(whatever, true)` rather than simply
`assert!(whatever)`. In this case, this occurs because the macro makes
an assertion about a request value, and in _some_ tests, the request
type is `bool`. We can't change this to use `assert!`, because in most
cases, when the request is not `bool`, we actually do need `assert_eq!`,
so I ignored that warning.
2022-02-11 11:11:15 -08:00
Eliza Weisman
665834c7a6
ci: disable fail-fast for Rust version matrix jobs (#640)
Tower has test and check jobs on CI that run on a build matrix
including a number of Rust versions. By default, GitHub Actions has
fail-fast semantics for matrix jobs, so if any matrix job fails, the
rest are cancelled and the build is failed. This is intended to help
builds complete faster.

This isn't really the ideal behavior for testing across multiple Rust
versions. When a build fails on a particular toolchain version, we would
ideally like to know whether the failure is localized to that version or
exists on _all_ Rust versions. This is particularly important for builds
on nightly Rust, as the nightly toolchain is more likely to contain
compiler regressions that might not be our fault at all. Similarly, we
might want to know if a change only broke the build on our MSRV, or if
it broke the build everywhere --- such an issue would be fixed
differently.

This also currently means that the nightly test run failing will prevent
PRs from being merged, even if the failure is due to a nightly compiler
regression. We currently only *require* the stable and MSRV test runs
to pass in order to merge a PR, but because the fail-fast behavior
will cancel them if the nightly build fails, this means that nightly failing
will effectively prevent merging PRs...which, given that it's not marked
as required, seems different from what we intended.

Therefore, this PR changes the CI workflow to disable fail-fast behavior
on the cross-version test jobs.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2022-02-11 11:05:03 -08:00
Oliver Gould
2f50b49f5a Avoid time operations that can panic
We have reports of runtime panics (linkerd/linkerd2#7748) that sound a
lot like rust-lang/rust#86470. We don't have any evidence that these
panics originate in tower, but we have some potentialy flawed `Instant`
arithmetic that could panic in this way.

Even though this is almost definitely a bug in Rust, it seems most
prudent to actively avoid the uses of `Instant` that are prone to this
bug.

This change replaces uses of `Instant::elapsed` and `Instant::sub` with
calls to `Instant::saturating_duration_since` to prevent this class of
panic. These fixes should ultimately be made in the standard library,
but this change lets us avoid this problem while we wait for those
fixes.

See also hyperium/hyper#2746
2022-01-31 16:23:47 -08:00
Jake Shadle
20d7b55556
chore: reenable all cargo deny checks (#632) 2022-01-31 09:27:27 +01:00
Christian Legnitto
71a1578f27
chore: Update links to layer list in README (#627)
Previous links were broken. These now link to https://docs.rs/tower/latest/tower/#modules.

Co-authored-by: Oliver Gould <ver@buoyant.io>
2022-01-18 08:08:23 +01:00
Jonas Platte
d0d8707ac0
Fix sometimes-unused dependencies (#603)
`tower` currently has required dependencies that may not be used
unless certain features are enabled.

This change updates `tower` to make these dependencies optional.

Furthermore, this change removes use of `html_root_url`, which is no
longer recommended (https://github.com/rust-lang/api-guidelines/pull/230),
and updates the documented release instructions.
2022-01-17 15:25:07 -08:00
Paolo Barbolini
7f004da56f
Import tracing without the attributes feature (#623)
tracing-attributes depends on syn and proc-macro2, which are slow to compile
2021-12-29 09:47:08 -08:00
Sibi Prabakaran
373a010ff5
Minor doc fix for buffer function (#622) 2021-12-24 10:55:07 +01:00
Oliver Gould
b20b3cbd57
Assert that no unsafe code is used in tower (#621)
The tower crates do not include any `unsafe` code, but tools like
[`cargo-geiger`][cg] can't necessarily detect that. This change adds a
stronger assertion at the top of each crate with a
`#![forbid(unsafe_code)]` directive to assert that no unsafe code is
used in the crate. This also serves as a more obvious obstacle to
introducing unsafe code in future changes.

[cg]: https://github.com/rust-secure-code/cargo-geiger
2021-11-24 15:26:16 -08:00
Qinxuan Chen
2d167204dc
tower: update hdrhistogram to 7.0 and remove useless dependencies (#620)
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
2021-11-19 10:12:48 +01:00
David Pedersen
7674109b28
tower: prepare to release 0.4.11 (#618)
* tower: prepare to release 0.4.11

Added

- **util**: Add `CloneBoxService` which is a `Clone + Send` boxed `Service` ([#615])
- **util**: Add `ServiceExt::boxed` and `ServiceExt::clone_boxed` for applying the
  `BoxService` and `CloneBoxService` middleware ([#616])
- **builder**: Add `ServiceBuilder::boxed` and `ServiceBuilder::clone_boxed` for
  applying `BoxService` and `CloneBoxService` layers ([#616])

Fixed

- **balance**: Remove redundant `Req: Clone` bound from `Clone` impls
  for `MakeBalance`, and `MakeBalanceLayer` ([#607])
- **balance**: Remove redundant `Req: Debug` bound from `Debug` impls
  for `MakeBalance`, `MakeFuture`, `Balance`, and `Pool` ([#607])
- **ready-cache**: Remove redundant `Req: Debug` bound from `Debug` impl
  for `ReadyCache` ([#607])
- **steer**: Remove redundant `Req: Debug` bound from `Debug` impl
  for `Steer` ([#607])
- **util**: Remove redundant `F: Clone` bound
  from `ServiceExt::map_request` ([#607])
- **docs**: Fix `doc(cfg(...))` attributes
  of `PeakEwmaDiscover`, and `PendingRequestsDiscover` ([#610])
- **util**: Remove unnecessary `Debug` bounds from `impl Debug for BoxService` ([#617])
- **util**: Remove unnecessary `Debug` bounds from `impl Debug for UnsyncBoxService` ([#617])

[#607]: https://github.com/tower-rs/tower/pull/607
[#610]: https://github.com/tower-rs/tower/pull/610
[#616]: https://github.com/tower-rs/tower/pull/616
[#617]: https://github.com/tower-rs/tower/pull/617
[#615]: https://github.com/tower-rs/tower/pull/615

* sorting

* Rename `CloneBoxService` to `BoxCloneService`

* formatting

* also update changelog
tower-0.4.11
2021-11-18 20:40:01 +01:00
David Pedersen
4d80f7ed90
builder,util: add convenience methods for boxing services (#616)
* builder,util: add convenience methods for boxing services

This adds a couple of new methods to `ServiceBuilder` and `ServiceExt`:

- `ServiceBuilder::boxed`
- `ServiceExt::boxed`
- `ServiceBuilder::clone_boxed`
- `ServiceExt::clone_boxed`

They apply `BoxService::layer` and `CloneBoxService::layer`
respectively.

* fix doc links

* add missing `cfg`s

* Update tower/CHANGELOG.md

Co-authored-by: Eliza Weisman <eliza@buoyant.io>

* Apply suggestions from code review

Co-authored-by: Eliza Weisman <eliza@buoyant.io>

* not sure why rustdoc cannot infer these

* line breaks

* trailing whitespace

* make docs a bit more consistent

* fix doc links

* update tokio

* don't pull in old version of tower

* Don't run `cargo deny check bans` as it hangs

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2021-11-18 13:56:19 +01:00
David Pedersen
48f8ae90a4
util: remove unnecessary Debug bounds from boxed services (#617) 2021-11-11 21:59:29 +01:00
David Pedersen
973bf71583
util: add CloneBoxService (#615)
* util: add `CloneService`

This upstreams a little utility I'm using a bunch in axum. Its often
useful to erase the type of a service while still being able to clone
it.

`BoxService` isn't `Clone` previously you had to combine it with
`Buffer` but doing that a lot (which we did in axum) had measurable
impact on performance.

* Address review feedback

* remove needless trait bounds
2021-11-09 21:39:27 +01:00
cppforliving
62df5e72b0
docs: Fix doc(cfg(...)) attributes (#610) (#610)
`RUSTDOCFLAGS='--cfg docsrs' cargo +nightly doc --all-features` outputs some warnings
```
warning: unused attribute `doc`
  --> tower/src/load/peak_ewma.rs:52:20
   |
52 | #[cfg_attr(docsrs, doc(cfg(feature = "discover")))]
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_attributes)]` on by default
note: the built-in attribute `doc` will be ignored, since it's applied to the macro invocation `pin_project`
  --> tower/src/load/peak_ewma.rs:53:1
   |
53 | pin_project! {
   | ^^^^^^^^^^^

warning: unused attribute `doc`
  --> tower/src/load/pending_requests.rs:31:20
   |
31 | #[cfg_attr(docsrs, doc(cfg(feature = "discover")))]
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: the built-in attribute `doc` will be ignored, since it's applied to the macro invocation `pin_project`
  --> tower/src/load/pending_requests.rs:32:1
   |
32 | pin_project! {
   | ^^^^^^^^^^^

warning: `tower` (lib doc) generated 2 warnings
```

This PR is an attempt to fix this.
2021-11-09 09:26:57 -08:00