Commit Graph

381 Commits

Author SHA1 Message Date
Steven Fackler 82e578b5b0
Impl Layer for &Layer (#446) 2020-04-21 17:11:27 -04: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 85b657bf93
Remove path deps for `tower-service` (#441) 2020-04-17 14:00:38 -04:00
Lucio Franco 5e1788f494
rate: Fix rate limit not resetting (#439) 2020-04-16 11:31:58 -04:00
Lucio Franco cd7dd12315
Refactor github actions (#436)
Signed-off-by: Lucio Franco <luciofranco14@gmail.com>
2020-04-14 19:20:20 -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 81cfbab19e
Merge pull request #432 from tower-rs/2020-spring-clean
2020: merge all the middleware
2020-03-31 16:55:48 -04:00
Jon Gjengset 9dd2314048
step 4: make features do the right thing 2020-03-31 16:26:53 -04:00
Jon Gjengset 2e06782241
step 3: make ci work again 2020-03-31 16:26:52 -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 0f9eb648a5
limit: prepare 0.3.1 release (#430) 2020-03-25 19:51:59 -04:00
Jon Gjengset 378433fc75
limit: Forward tower_load::Load (#429) 2020-03-25 19:46:05 -04:00
Jon Gjengset b575175210
util: prepare 0.3.1 release (#428) 2020-03-23 13:02:43 -04:00
Jon Gjengset 52fde9767c
util: Add ReadyAnd to do what Ready should do (#427)
* util: Add ReadyAnd to do what Ready should do

`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.
2020-03-23 12:49:44 -04:00
Jon Gjengset b6f5f586c5
Add Buffer::new note on how to set bound (#425) 2020-03-04 15:48:33 -05:00
Jake Ham 52d9e95a38
Fix documentation links in README (#422)
Updated the README, fixing the links to documentation. This now links
to each packages documentation on docs.rs. Not all packages have been
released to crates.io, so their documentation pages are empty.
2020-02-27 11:42:08 -05:00
Jon Gjengset ba1fdd755b ready-cache: Prepare for 0.3.1 release
This also fixes up the various documentation URLs, which were still
pointing to 0.1.x.
2020-02-24 13:14:23 -05:00
Jon Gjengset 414e3b0809
ready-cache: Avoid panic on strange race (#420)
It's been observed that occasionally tower-ready-cache would panic
trying to find an already canceled service in `cancel_pending_txs`
(#415). The source of the race is not entirely clear, but extensive
debugging demonstrated that occasionally a call to `evict` would send on
the `CancelTx` for a service, yet that service would be yielded back
from `pending` in `poll_pending` in a non-`Canceled` state. This
is equivalent to saying that this code may panic:

```rust
async {
  let (tx, rx) = oneshot::channel();
  tx.send(42).unwrap();
  yield_once().await;
  rx.try_recv().unwrap(); // <- may occasionally panic
}
```

I have not been able to demonstrate a self-contained example failing in
this way, but it's the only explanation I have found for the observed
bug. Pinning the entire runtime to one core still produced the bug,
which indicates that it is not a memory ordering issue. Replacing
oneshot with `mpsc::channel(1)` still produced the bug, which indicates
that the bug is not with the implementation of `oneshot`. Logs also
indicate that the `ChannelTx` we send on in `evict()` truly is the same
one associated with the `ChannelRx` polled in `Pending::poll`, so we're
not getting our wires crossed somewhere. It truly is bizarre.

This patch resolves the issue by considering a failure to find a
ready/errored service's `CancelTx` as another signal that a service has
been removed. Specifically, if `poll_pending` finds a service that
returns `Ok` or `Err`, but does _not_ find its `CancelTx`, then it
assumes that it must be because the service _was_ canceled, but did not
observe that cancellation signal.

As an explanation, this isn't entirely satisfactory, since we do not
fully understand the underlying problem. It _may_ be that a canceled
service could remain in the pending state for a very long time if it
does not become ready _and_ does not see the cancellation signal (so it
returns `Poll::Pending` and is not removed). That, in turn, might cause
an issue if the driver of the `ReadyCache` then chooses to re-use a key
they believe they have evicted. However, any such case _must_ first hit
the panic that exists in the code today, so this is still an improvement
over the status quo.

Fixes #415.
2020-02-24 13:03:43 -05:00
Jon Gjengset be156e733d ready-cache: restore assert for dropped cancel tx
When ready-cache was upgraded from futures 0.1 to `std::future` in
e2f1a49cf3, this `expect` was removed, and
the code instead silently ignores the error. That's probably not what we
want, so this patch restores that assertion.
2020-02-20 17:08:07 -05:00
Jon Gjengset 1a67100aab Restore commented-out p2c assertion 2020-02-20 16:33:54 -05:00
Jon Gjengset ae34c9b4a1 Add more tower-ready-cache tests 2020-02-20 16:33:54 -05:00
Jon Gjengset 96529148d8 Remove irrelevant comment
The assertion there isn't even true anyway, since the p2c may not yet
have "seen" the removal of a service, because it stopped when it found a
ready service.
2020-02-20 16:01:19 -05:00
Jon Gjengset 650e5be58e balance: Add a stress test for p2c
The hope for this was to reproduce #415 (which it does not sadly), but
at least it adds a test for p2c!
2020-02-20 16:01:19 -05:00
Jon Gjengset 47c3a14560 tower: Prepare 0.3.1 release 2020-01-17 22:53:08 -05:00
Jon Gjengset ccfe7da592 tower: Allow opting out of tracing/log
This is of particular importance since the `log` feature of `tracing`
(currently) fails to compile if the `tracing` dependency is renamed.
Without a way to disable it in `tower`, any package that both depends on
`tower` **and** renames `tracing` in its dependencies is doomed.
2020-01-17 17:01:43 -05:00
Lucio Franco 7e35b758be
Remove azure and rename gh actions (#409)
* Remove azure

* Rename actions

* Rename workflow

* Reduce amount of actions

* Fix patch
2020-01-09 19:23:03 -05:00
László Nagy 40103d84ce Use GitHub actions (#407)
* gh-403: add basic github actions

* gh-403: add environment variables during test

* gh-403: fix error in tower-balance example

* gh-403: rename build workflow

* gh-403: fix release workflow

* gh-403: add GitHub page publish workflow

* gh-403: remove release workflow

* gh-403: run per crate build

* gh-403: replace build to check
2020-01-09 19:02:40 -05:00
Lucio Franco 7b48479bd2
util: Remove dev dep on tower (#401)
* util: Remove dev dep on tower

* Fix rustc bug

* enable call-all by default
2019-12-19 18:17:21 -05:00
Lucio Franco d63665515c
ready-cache: Add readme (#402) 2019-12-19 17:56:43 -05:00
Lucio Franco fe7919b1a4
Use `Into<Error>` for all Services (#400) 2019-12-19 17:30:23 -05:00
Lucio Franco 86eef82d2f
Remove default features for futures dep (#399)
* Remove default features for futures dep

* Add missing alloc feature
2019-12-19 14:20:41 -05:00
Lucio Franco 1e87d7ca8b
Bump crates and changelog dates (#397) 2019-12-19 13:44:40 -05:00
Lucio Franco 2fede40bdb
balance: Upgrade rand to 0.7 (#398) 2019-12-19 13:44:07 -05:00
Sean McArthur 2dc9a72bea tower-util: remove dead code 2019-12-11 13:13:07 -08:00
Sean McArthur 1863304331 move ServiceExt to tower-util crate 2019-12-11 12:13:51 -08:00
Lucio Franco 2e9e2d1813
limit: Vendor `tokio::sync::Semaphore` (#388) 2019-12-11 15:08:42 -05:00
Lucio Franco fd2d034e97
ci: Re-enable ci (#389)
* ci: Re-enable ci

* ci: Re-enable ci

* Actually use stable
2019-12-11 15:01:02 -05:00
Sean McArthur f6650b90c7 re-enable CI for tower-layer and tower-util 2019-12-11 11:25:13 -08:00
Sean McArthur f130e5e113 tower-util: reduce dependencies, make call-all optional 2019-12-11 11:25:13 -08:00
Juan Alvarez 1843416dfe remove service, make and layer path deps (#382) 2019-12-06 11:59:56 -05:00
Lucio Franco 423ecee7e9
Remove unused deps (#381) 2019-12-05 23:42:01 -05:00
Lucio Franco fdc7460f5a
Add rt-core feature to buffer (#380) 2019-12-05 20:17:36 -05: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