Commit Graph

56 Commits

Author SHA1 Message Date
Taiki Endo b12a3e3ae9
Remove uses of pin_project::project attribute (#458)
pin-project will deprecate the project attribute due to some unfixable
limitations.

Refs: https://github.com/taiki-e/pin-project/issues/225
2020-06-15 12:38:34 -04:00
Bruce Guenter 98e0e41db1
Rework ConcurrencyLimit to use upstream tokio Semaphore (#451) 2020-05-06 11:06:40 -04:00
Jon Gjengset 1c2d50680a
Spring cleaning for tower::balance (#449)
Noteworthy changes:

 - All constructors now follow the same pattern: `new` uses OS entropy,
   `from_rng` takes a `R: Rng` and seeds the randomness from there.
   `from_rng` is fallible, since randomness generators can be fallible.
 - `BalanceLayer` was renamed to `MakeBalanceLayer`, since it is not
   _really_ a `BalanceLayer`. The name of `BalanceMake` was also
   "normalized" to `MakeBalance`.

Another observation: the `Debug` bound on `Load::Metric` in
`p2c::Balance`, while not particularly onerous, generates really
confusing errors if you forget it include it. And crucially, the error
never points at `Debug` (should we file a compiler issue?), so I pretty
much had to guess my way to that being wrong in the doc example.

It would probably be useful to add a documentation example to
`MakeBalanceLayer` or `MakeBalance` (I suspect just one of them is fine,
since they're basically the same). Since I've never used it, and find it
hard to think of uses for it, it might be good if someone with more
experience with it wrote one.
2020-04-24 13:21:11 -04:00
Jon Gjengset 6a25d322b5 Use only one alias for Box<dyn Error>
This was a mostly mechanical change. I think in at least one place it
results in a `'static` bound being added, but the next tower release
will be breaking anyway, so that's okay.

I think it helps to also document the alias at the top to (eventually)
explain how people can interact with the error they get back to discover
the "deeper cause".
2020-04-24 10:30:20 -04:00
Eliza Weisman 8752a38117
util: fix oneshot dropping pending services immediately (#447)
## Motivation

Commit #330 introduced a regression when porting `tower-util::Oneshot`
from `futures` 0.1 to `std::future`. The *intended* behavior is that a
oneshot future should repeatedly call `poll_ready` on the oneshotted
service until it is ready, and then call the service and drive the
returned future. However, #330 inadvertently changed the oneshot future
to poll the service _once_, call it if it is ready, and then drop it,
regardless of its readiness.

In the #330 version of oneshot, an `Option` is used to store the
request while waiting for the service to become ready, so that it can be
`take`n and moved into the service's `call`. However, the `Option`
contains both the request _and_ the service itself, and is taken the
first time the service is polled. `futures::ready!` is then used when
polling the service, so the method returns immediate if it is not ready.
This means that the service itself (and the request), which were taken
out of the `Option`, will be dropped, and if the oneshot future is
polled again, it will panic.

## Solution

This commit changes the `Oneshot` future so that only the request lives
in the `Option`, and it is only taken when the service is called, rather
than every time it is polled. This fixes the bug.

I've also added a test for this which fails against master, but passes
after this change.
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-04-23 16:07:48 -07:00
Jon Gjengset 39112cb0ba
Tidy up tower::load (#445)
This also renames the `Instrument` trait, and related types, to better
reflect what they do. Specifically, the trait is now called
`TrackCompletion`, and `NoInstrument` is called `CompleteOnResponse`.

Also brings back balance example and makes it compile.
2020-04-20 14:55:40 -04:00
Jon Gjengset 05b165056b
Tidy up tower::buffer (#444) 2020-04-17 17:41:51 -04:00
Jon Gjengset c87fdd9c1e
Change Discover to be a sealed trait (#443)
* Change Discover to be a sealed trait

`Discover` was _really_ just a `TryStream<Item = Change>`, so this
change makes that much clearer. Specifically, users are intended to use
`Discover` only in bounds, whereas implementors should implement
`Stream` with the appropriate `Item` type. `Discover` then comes with a
blanket implementation for anything that implements `TryStream`
appropriately. This obviates the need for the `discover::stream` module.
2020-04-17 16:27:44 -04:00
Jon Gjengset 5947e2e145
Some more spring clean fixes. (#442)
* Add doc feature annotations

* Modules should be published or removed
2020-04-17 16:03:15 -04:00
Lucio Franco 5e1788f494
rate: Fix rate limit not resetting (#439) 2020-04-16 11:31:58 -04:00
Lucio Franco 8a73440c1a
reconnect: Rework to allow real reconnecting (#437)
Signed-off-by: Lucio Franco <luciofranco14@gmail.com>
Co-authored-by: Jon Gjengset <jon@thesquareplanet.com>
2020-04-14 16:42:37 -04:00
Lucio Franco d34019045f
Add `Map` service combinator (#435)
Signed-off-by: Lucio Franco <luciofranco14@gmail.com>
Co-authored-by: David Barsky <dbarsky@amazon.com>
2020-04-14 15:16:16 -04:00
Akshay Narayan 0520a6a467
New sub-crate: tower-steer (#426) 2020-03-31 21:26:13 -04:00
Jon Gjengset c4d70b535b
step 2: make all the tests work again 2020-03-31 16:12:32 -04:00
Jon Gjengset 8df2a3e410
step 1: move all things to where they're going
Note that this also moves all crates from `log` to `tracing`.
It also does not set any dependencies as optional.
2020-03-31 13:31:21 -04:00
Jon Gjengset 47c3a14560 tower: Prepare 0.3.1 release 2020-01-17 22:53:08 -05:00
Sean McArthur 1863304331 move ServiceExt to tower-util crate 2019-12-11 12:13:51 -08:00
Lucio Franco e2f1a49cf3
Update the rest of the crates and upgrade ready cache to `std::f… (#379)
* Update hedge, filter, load, load-shed, and more

* Update ready cache

* Prepare release for ready-cache

* fix merge

* Update balance

* Prepare balance release
2019-12-05 14:21:47 -05:00
Lucio Franco 0d2a3778ad
Update `tower` and `tower-util` and prep for release (#378)
* Update tower and tower-util

* Prepare them for release

* fmt

* Get tower tests working
2019-12-04 22:48:43 -05:00
Jon Gjengset 2653f70884 Bumps for 0.3.0-alpha.2 (#355)
* Bump all to futures-* alpha.19

* Prepare for alpha.2 release

* Make tower-service also a path dep

* Use new tokio alpha
2019-09-30 18:56:26 -04:00
Jon Gjengset 6baf381879
Consistently apply deny/warn rules (#352)
This makes all tower subcrates have the following lints as warn (rather
than allow): `missing_docs`, `rust_2018_idioms`, `unreachable_pub`, and
`missing_debug_implementations`. In addition, it consistently applies
`deny(warning)` *only* under CI so that deprecations and macro changes in minor
version bumps in dependencies will never cause `tower` crates to stop
compiling, and so that tests can be run even if not all warnings have been
dealt with. See also https://github.com/rust-unofficial/patterns/blob/master/anti_patterns/deny-warnings.md

Note that `tower-reconnect` has the `missing_docs` lint disabled for now
since it contained _no_ documentation previously. Also note that this
patch does not add documentation to the various `new` methods, as they
are considered self-explanatory. They are instead marked as
`#[allow(missing_docs)]`.
2019-09-23 17:28:14 -04:00
Lucio Franco 206f3d9941
Prepare `tower-buffer` 0.3.0-alpha.1a release (#343)
Signed-off-by: Lucio Franco <luciofranco14@gmail.com>
2019-09-13 16:36:35 -04:00
Jon Gjengset 395889c763
Make Ready only take Service by reference (#340)
Rather than consuming `self` and returning `(Self, _)`. This did mean
that a few crates that depended on `Ready` to own the `Service` and
provide it once it was ready had to change to call `poll_ready`
directly. Which in turn meant adding in some PhantomData<Request> so
that the impl blocks wouldn't be under-constrainted. Take, for example:

```
impl<K, S: Service<Req>, Req> Future for UnreadyService<K, S>
```

would fail to compile with

```
error[E0207]: the type parameter `Req` is not constrained by the impl trait, self type, or predicates
```
2019-09-11 15:49:51 -04:00
Jon Gjengset 0802ca2bce
Update tower-util and tower to std::future (#330)
This bumps tower-util and tower to 0.3.0-alpha.1
2019-09-10 14:51:07 -04:00
Lucio Franco 72219ce862
Prep buffer and tower release (#305)
* Prep buffer 0.1.1 release

* Prep release for tower 0.1.1
2019-07-19 14:21:07 -04:00
Oliver Gould b39a4881d8
builder: Add `into_inner` (#299)
When using a `ServiceBuilder`, it's not possible to obtain the
underlying `Layer` implementation.

Adding a `ServiceBuilder::into_inner` allows callers to retrieve this
field instead of only being able to build a `Service`.
2019-07-09 11:43:59 -07:00
Sean McArthur b9c2fea0fc Greatly improve Debug output of ServiceBuilder (#280) 2019-05-09 08:44:40 -07:00
Carl Lerche 14f4259518
Prepare release (#273)
The following crates are to be released:

- tower
- tower-buffer
- tower-discover
- tower-layer
- tower-limit
- tower-load-shed
- tower-retry
- tower-service
- tower-test
- tower-timeout
- tower-util
2019-04-26 21:31:25 -07:00
Sean McArthur d0d6ed54cf unify/improve style of docs shown by facade 2019-04-23 14:08:51 -07:00
Sean McArthur 0cc6cc0c78 inline docs for re-exported crates in facade (#266) 2019-04-23 12:46:02 -07:00
Sean McArthur 484cbe7556 Remove `ServiceBuilder::make_service()` 2019-04-23 12:08:21 -07:00
Sean McArthur c339f4bf13 Remove reconnect from tower facade 2019-04-23 11:28:56 -07:00
Sean McArthur 57a866ee09 remove Service bounds on ServiceBuilder::service() 2019-04-22 13:34:38 -07:00
Carl Lerche 07baf63048 Remove bounds of `Service` from `Layer` 2019-04-22 13:34:38 -07:00
Sean McArthur d1c891d1ba
Promote service_fn to tower crate (#248) 2019-04-10 13:17:16 -07:00
Carl Lerche 0f58e50c3d
Rename `Chain` -> `Stack` (#239)
Reduce metaphors.

Fixes #233
2019-04-09 13:09:44 -07:00
David Barsky 17860191d7 Move Tower to 2018 Edition (#238) 2019-04-08 20:11:09 -07:00
Carl Lerche 7769590f46
Remove balance and filter from tower (#240)
These two crates will need to be finished at a later time.
2019-04-08 14:49:24 -07:00
Carl Lerche 16f2d2b4fa
Consolidate `limit` layers (#235)
* Consolidate `limit` layers

- `InFlightLimit` and `RateLimit` are moved into `tower-limit` crate.
- `InFlightLimit` is renamed to `ConcurrencyLimit`.

Fixes #225
2019-04-05 20:08:43 -07:00
Carl Lerche 971bb06152
Provide layer specific fns on `ServiceBuilder` (#227) 2019-04-03 20:40:06 -07:00
Carl Lerche 298fe2cc12
Rename `ServiceBuilder` builder fns. (#228)
Closes #226
2019-04-03 19:33:28 -07:00
Lucio Franco 486c533989
tower: Reexport all layers and add layer::util mod (#224)
* tower: Reexport all layers and add layer::util mod

* Fix crate names and layerext
2019-04-03 12:12:11 -04:00
Carl Lerche 9983347392
re-export layers from `tower` crate. (#222) 2019-04-02 16:22:23 -07:00
Carl Lerche 83be955afe
Rename OptionService -> Optional (#219)
Other service implementations do not have the Service suffix.
2019-03-29 19:17:11 -07:00
Carl Lerche 117018f319
Rename `EitherService` -> `Either` (#218) 2019-03-29 19:17:02 -07:00
Carl Lerche 019129829c
Move layer::{LayerExt, Chain, Identity} (#216)
- `tower-layer` util types are now in `tower-util`.
- `LayerExt` is now in `tower`.

This sets the stage for adding layer specific extension fns.
2019-03-29 14:28:06 -07:00
Lucio Franco da4e22c89d
Add missing `TimeoutLayer` to tower (#215)
Signed-off-by: Lucio Franco <luciofranco14@gmail.com>
2019-03-29 17:00:13 -04:00
Carl Lerche f6dcbb6ca1
Remove combinators (#214) 2019-03-27 20:16:07 -07:00
Carl Lerche 3a407c2775
Move misc types (#213) 2019-03-27 19:56:44 -07:00
Carl Lerche f1bb22a296
util: rename tower-service-util -> tower-util (#212) 2019-03-27 16:34:56 -07:00