574 Commits

Author SHA1 Message Date
David Barsky
646804d77e
chore: prepare to release tower-0.5.0, tower-layer-0.3.3, tower-service-0.3.3, and tower-test-0.4.1 (#781) tower-service-0.3.3 2024-08-02 15:21:30 -04:00
Dirk Stolle
7202cfeecd
chore: fix a few typos (#780) 2024-07-23 19:54:14 -04:00
Glen De Cauwsemaecker
85080a5617
use workspace dependencies for tower (#778)
Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>
2024-07-23 11:26:01 -04:00
Glen De Cauwsemaecker
88a7d3e01e
fix warnings found when running check/doc commands (#779)
Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>
2024-07-23 10:55:12 -04:00
Dirk Stolle
a6e98a7d69
chore: update GitHub Actions CI (#740) 2024-07-23 09:37:48 -04:00
Toby Lawrence
74e925d2c8
chore: fix spelling errors (#775)
Co-authored-by: Dirk Stolle <striezel-dev@web.de>
2024-07-21 12:36:46 -04:00
Daniél Kerkmann
89ac74f320
feat: Make new functions const when possible (#760)
* feat: Make new functions const when possible

The main reason was to allow to initialize the RateLimitLayer in a const context.
So why not making ever new function const (wherever it's possible). :P

* Change the assert to use an MSRV-compatible function.

---------

Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>
2024-07-20 13:18:29 -04:00
Glen De Cauwsemaecker
032d17f689
ensure that re-exported symbols show feature label in root (#754)
Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>
2024-07-20 13:11:02 -04:00
Josh Stone
05a0a25dcc
Upgrade to indexmap v2 (MSRV 1.63) (#741)
Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>
2024-07-20 13:01:30 -04:00
Glen De Cauwsemaecker
7d723eb2fa
remove generic parameters from Reconnect::new (#755)
these were not used, as the only parameters used
come from the impl block (directly and indirectly)

Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>
2024-07-20 12:42:34 -04:00
tottoto
f286933bec
chore: Remove unmatched deny ignore config (#733)
Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>
2024-07-20 12:31:24 -04:00
mxsm
08917603c1
docs: Fix some spelling mistakes (#747) 2024-07-19 16:27:07 -04:00
Eric Crosson
39adf5c509
docs: fix grammar (#749)
This commit uses the correct form of "it's".

"Its" is possessive describes a noun, while "it's" is a contraction that
is short for "it is". Since "ready" is not a noun, we must use the
contraction in this case.

In addition, this commit adds some missing commas.

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2023-11-06 21:27:25 +00:00
0x5459
a4c20a388b chore: remove useless code 2023-11-06 16:12:37 -05:00
a-kenji
bf4ea94834
docs: Fix duplicate words in README (#734) 2023-05-16 19:34:51 +00:00
Misha Zharov
be1a4faf66
Check if must_use will fix the issue (#728) 2023-04-28 11:38:59 +02:00
qthree
0c3ae8856e
Derive Clone for AsyncFilterLayer (#731) 2023-04-21 15:25:52 +02:00
Misha Zharov
0604f20c48
Bump version numbers (#729) 2023-04-11 18:55:52 +02:00
Adrien Guillo
d2f1703c48
Derive Clone for RetryLayer (#726) 2023-03-24 21:59:48 +00:00
Spencer Bartholomew
664cb35abb
Fix axum readme link (#721) 2023-02-26 18:37:05 +01:00
Spencer Bartholomew
64182d8243
Recommend Axum instead of Warp (#720) 2023-02-26 15:46:02 +01:00
Jeffrey Hutchins
74881d5311
Copy editing building-a-middleware-from-scratch.md (#718) 2023-01-31 19:42:19 +01:00
Conrad Ludgate
b01bb12ddd
rng: use a simpler random 2-sampler (#716) 2023-01-10 12:11:30 -05:00
Frederik Haaning
6f3050614f
timeout: fix typo in docs (#711) 2022-12-01 11:06:11 -05:00
David Pedersen
c34182d0b3
util: make BoxService impl Sync via SyncWrapper (#702)
* util: make `BoxService` impl `Sync` via `SyncWrapper`

* changelog

* format
2022-11-27 10:09:18 +00:00
JJ Ferman
387d2844b7
Updating generic to be consistent (#710) 2022-11-09 08:02:13 +01:00
Alex Rudy
787f5dd81b
util: Adds a BoxCloneServiceLayer (#708)
This layer is similar to a BoxLayer, but produces a BoxCloneService instead, so can be used when
the underlying layers must be clone.

Co-authored-by: Lucio Franco <luciofranco14@gmail.com>
2022-11-04 11:06:23 -04:00
Leonardo Yvens
c9d84cde0c
util: Two call_all bug fixes (#709)
One is handling poll_ready errors (#706).

The other is fixing the TODO about disarming poll_ready, since there is no disarm this makes sure
`poll_ready` is only called if `call` will immediately follow.
2022-11-01 15:28:09 -04:00
boraarslan
d27ba65891
retry: Add Budget trait (#703) 2022-10-24 18:28:22 +00:00
Heiko Seeberger
582a0e0c74
util: improve ServiceExt::oneshot docs (#704) 2022-10-24 16:02:51 +00:00
Sam Lewis
c049ded33f
discover: Implement Clone for Change (#701)
Implements Clone for discover::Change, if the underlying key and value
both implement clone.

This is convenient for use-cases where a single change needs to be
duplicated, and sent to multiple discover streams.

Co-authored-by: Lucio Franco <luciofranco14@gmail.com>
2022-10-17 18:41:55 +00:00
Sam Lewis
7d829f198e
ready-cache: Allow iteration over ready services (#700)
Adds `iter_ready` and `iter_ready_mut` to allow iteration over ready
services within the ready_cache. This allows the ready cache to be used
for router-like services that wish to direct requests towards specific
services. Allowing iteration directly means that cache keys do not have
to be redundantly stored separate to the ready_cache.
2022-10-17 13:19:26 -04:00
Jonas Platte
87fa8ef782
layer: Implement Layer for tuples of up to 16 elements (#694) 2022-10-04 18:54:39 +00:00
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