Commit Graph

68 Commits

Author SHA1 Message Date
Lucio Franco b6c67182cb
make: Prepare 0.3 release and update docs (#370)
* make: Prepare 0.3 release and update docs

* rebase against origin/master + get doc tests to compile

* fmt

* fix build
2019-11-29 15:44:03 -05:00
Lucio Franco c3c6780d31
service: Update docs and prepare for 0.3 release (#369)
* service: Update docs and prepare for 0.3 release

* Update rustmft

* Disable main tower crate
2019-11-29 11:48:08 -05:00
Lucio Franco bb5c02ca58
Disable all crates execpt tower-service 2019-11-29 09:23:54 -05:00
David Barsky a4c02f5d9c Revert "get building"
186a0fb4a3
2019-11-28 15:21:27 -05:00
David Barsky 186a0fb4a3 get building 2019-11-28 15:15:41 -05:00
Lucio Franco 87ad2e1cc8 Merge remote-tracking branch 'origin/master' into v0.3.x 2019-11-26 10:32:02 -05:00
Oliver Gould 7e55b7fa0b
Introduce tower-ready-cache (#303)
In #293, `balance` was refactored to manage dispatching requests over a
set of equivalent inner services that may or may not be ready.

This change extracts the core logic of managing a cache of ready
services into a dedicated crate, leaving the balance crate to deal with
node selection.
2019-11-12 09:44:16 -08:00
Lucio Franco abe5b78542
Remove tokio alpha.6 patches (#357)
* Remove tokio alpha.6 patches

* Remove ci patch
2019-09-30 21:15:26 -04:00
Taiki Endo 03dc7069aa Update pin-project to 0.4 (#350) 2019-09-30 14:58:27 -04:00
Jon Gjengset 3d642f5ca0
This bumps tower-hedge to 0.3.0-alpha.1 (#334) 2019-09-11 14:00:22 -04:00
Jon Gjengset 87976ae418
Update tower-balance to std::future (#335)
This bumps tower-balance to 0.3.0-alpha.1

It also adds delegate impls for `Discover` through `Pin`, and makes `tower-load::Constant: Debug`.
2019-09-10 18:15:32 -04:00
Jon Gjengset 1ca999fde1
Update tower-spawn-ready to std::future (#332)
This bumps tower-spawn-ready to 0.3.0-alpha.1
2019-09-10 17:06:34 -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
Jon Gjengset 9691d0d379
Update tower-reconnect to std::future (#333)
This bumps tower-reconnect to 0.3.0-alpha.1

It also makes the tower-make version consistent
2019-09-10 11:48:01 -04:00
Jon Gjengset adca66cf74
Update tower-filter to std::future (#331)
This bumps tower-filter to 0.3.0-alpha.1
2019-09-10 11:39:51 -04:00
Jon Gjengset 4eb47b01dc
Update tower-timeout to std::future (#328)
This bumps tower-timeout to 0.3.0-alpha.1
2019-09-09 16:20:09 -04:00
Jon Gjengset 4f71951221
Update tower-retry to std::future (#326)
This bumps tower-retry to 0.3.0-alpha.1
2019-09-09 15:10:46 -04:00
Jon Gjengset 154bd69b9f
Update tower-limit to std::future (#324)
This bumps tower-limit to 0.3.0-alpha.1
2019-09-09 12:09:41 -04:00
Jon Gjengset 390e124525
Update tower-load-shed to std::future (#325)
This bumps tower-load-shed to 0.3.0-alpha.1
2019-09-09 12:09:19 -04:00
Jon Gjengset 693965fa4a
Update tower-buffer to std::future (#323)
This bumps tower-buffer to 0.3.0-alpha.1
2019-09-09 12:07:28 -04:00
Jon Gjengset f8097a60f6
Update tower-load to std::future (#321)
This bumps tower-load to 0.3.0-alpha.1
2019-09-09 09:22:49 -04:00
Jon Gjengset db116d1937
Update tower-layer to std::future (#322)
This bumps tower-layer to 0.3.0-alpha.1
2019-09-07 00:22:18 -04:00
Jon Gjengset 5ad02b73d9
Update tower-discover to std::future (#320)
This bumps tower-discover to 0.3.0-alpha.1
2019-09-07 00:20:21 -04:00
John Doneth 7ae5967e7a Update tower-test to std::future::Future (#316)
* update tower-test to std::future

* refactoring tower-test tests

* everything works

* whoops, un-delete the tower dir

* cleanup & update links

* undo changes to tower-filter for this PR

* use pin_utils::unsafe_pinned

* use tokio-test
2019-09-03 10:26:46 -04:00
Stan Bondi ae611db665 Update `service_fn` to `std::future::Future` (#318)
This small PR ports service_fn to `std::future`.
2019-09-03 10:12:33 -04:00
Lucio Franco 652137aaa3
Update MakeService and MakeConnection (#313)
* Update MakeService and MakeConnection

* Create tower-make crate

* Remove Makers from tower-util
2019-08-27 12:39:14 -04:00
Lucio Franco fe9cef6006
Update `tower-service` to `std::future::Future` (#311) 2019-08-20 14:31:09 -04:00
Oliver Gould a496fbf72c
Extract tower-load from tower-balance (#285)
The tower-balance crate includes the `Load` and `Instrument` traits,
which are likely useful outside of balancers; and certainly have no
tight coupling with any specific balancer implementation. This change
extracts these protocol-agnostic traits into a dedicated crate.

The `Load` trait includes a latency-aware _PeakEWMA_ load strategy as
well as a simple _PendingRequests_ strategy for latency-agnostic
applications.

The `Instrument` trait is used by both of these strategies to track
in-flight requests without knowing protocol details. It is expected that
protocol-specific crates will provide, for instance, HTTP
time-to-first-byte latency strategies.

A default `NoInstrument` implementation tracks the a request until its
response future is satisfied.

This crate should only be published once tower-balance is published.

Part of https://github.com/tower-rs/tower/issues/286
2019-05-29 10:32:02 -07:00
Oliver Gould 42f4b7781e
spawn-ready: Drives a service's readiness on an executor (#283)
Some layers cannot guarantee that they will poll inner services in a
timely fashion. For instance, the balancer polls its inner services to
check for readiness, but it does so randomly. If its inner service
must be polled several times to become ready, e.g., because it's driving
the initiation of a TLS connection, then the balancer may not drive the
handshake to completion.

The `SpawnReady` layer ensures that its inner service is driven to
readiness by spawning a background task.
2019-05-29 09:57:46 -07:00
Alex Leong 73c74252e6 Add hedge retry middleware (#236)
Add tower-hedge, a layer that preemptively retries requests which have been
outstanding for longer than a given latency percentile.  If either of the original
future or the retry future completes, that value is used.  For more information
about hedge requests, see: [The Tail at Scale][1]

[1]: https://cseweb.ucsd.edu/~gmporter/classes/fa17/cse124/post/schedule/p74-dean.pdf

Signed-off-by: Alex Leong <alex@buoyant.io>
2019-04-27 09:32:26 -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
Carl Lerche ef6d203b47
Create `tower-test` and include tower-mock. (#237)
tower-mock is deleted in favor of having a single test crate. This crate
also includes a new macro: `assert_request_eq!`.
2019-04-07 20:42:18 -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 f1bb22a296
util: rename tower-service-util -> tower-util (#212) 2019-03-27 16:34:56 -07:00
Lucio Franco 476f085c89
Introduce the `ServiceBuilder` (#175)
The `ServiceBuilder` composes layers together and produces either a `MakeService` or a `Service` wrapped by those layers.
2019-03-26 10:14:42 -04:00
Sean McArthur db2f0ecfb3
Introduce tower-load-shed (#204)
Provides a middleware that immediately fails any request if the
underlying service isn't ready yet. This is useful when used in
conjunction with `InFlightLimit` or others, so that requests are
rejected immediately, instead of keeping track of extra pending
requests.
2019-03-20 15:48:10 -07:00
Carl Lerche 263c680ea6 Remove tower-watch (#200) 2019-03-19 18:18:59 -07:00
Carl Lerche 92f4a0cb72
Rename tower-util -> tower (#197) 2019-03-15 10:53:19 -07:00
Carl Lerche acda5a75b9
Initial introduction of tower-service-util (#193) 2019-03-14 11:27:36 -07:00
Carl Lerche 794aa44c4b
Create subdir for tower crate (#182) 2019-03-06 07:54:39 -08:00
Lucio Franco c5d70481bd
layer: Add `tower-layer` and the `Layer` trait (#163)
This change introduces the new `tower-layer` crate and the foundational `Layer` trait to go along with it. This trait allows one to easily compose a set of `Service`s that take an inner service. These services only modify the request/response. This also provides the `Layer` implementation for many of the tower crates.
2019-02-27 15:28:42 -05:00
Carl Lerche 25eb52153d
Remove DirectService (#160) 2019-02-16 10:21:59 -08:00
Carl Lerche 1b8dc7149a
Remove tower-router (#153)
The current implementation is not ideal and there is no plan to work on
it in the near term.
2019-01-28 12:15:13 -08:00
Lucio Franco e6a3f76707 Add initial base tower crate (#149)
This adds the inital base tower crate, as of right now it contains
nothing and is only needed to ensure that cargo workspaces can
properly compile with rust 1.32.

See also rust-lang/rust#57524. Previously, the examples were
never even compiled.
2019-01-19 12:47:03 -05:00
Jon Gjengset 9bae225918 Add the DirectService trait (#118)
This patch adds the `DirectService` trait, and related implementations
over it in `tower_balance` and `tower_buffer`. `DirectService` is
similar to a `Service`, but must be "driven" through calls to
`poll_service` for the futures returned by `call` to make progress.

The motivation behind adding this trait is that many current `Service`
implementations spawn long-running futures when the service is created,
which then drive the work necessary to turn requests into responses. A
simple example of this is a service that writes requests over a
`TcpStream` and reads responses over that same `TcpStream`. The
underlying stream must be read from to discover new responses, but there
is no single entity to drive that task. The returned futures would share
access to the stream (and worse yet, may get responses out of order),
and then service itself is not guaranteed to see any more calls to it as
the client is waiting for its requests to finish.

`DirectService` solves this by introducing a new method, `poll_service`,
which must be called to make progress on in-progress futures.
Furthermore, like `Future::poll`, `poll_service` must be called whenever
the associated task is notified so that the service can also respect
time-based operations like heartbeats.

The PR includes changes to both `tower_balance::Balance` and
`tower_buffer::Buffer` to add support for wrapping `DirectService`s. For
`Balance` this is straightforward: if the inner service is a `Service`,
the `Balance` also implements `Service`; if the inner service is a
`DirectService`, the `Balance` is itself also a `DirectService`. For
`Buffer`, this is more involved, as a `Buffer` turns any `DirectService`
*into* a `Service`. The `Buffer`'s `Worker` is spawned, and will
therefore drive the wrapped `DirectService`.

One complication arises in that `Buffer<T>` requires that `T: Service`,
but you can safely construct a `Buffer` over a `DirectService` per the
above. `Buffer` works around this by exposing

```rust
impl Service for HandleTo<S> where S: DirectService {}
```

And giving out `Buffer<HandleTo<S>>` when the `new_directed(s: S)`
constructor is invoked. Since `Buffer` never calls any methods on the
service it wraps, `HandleTo`'s implementation just consists of calls to
`unreachable!()`.

Note that `tower_buffer` now also includes a `DirectedService` type,
which is a wrapper around a `Service` that implements `DirectService`.
In theory, we could do away with this by adding a blanket impl:

```rust
impl<T> DirectedService for T where T: Service {}
```

but until we have specialization, this would prevent downstream users
from implementing `DirectService` themselves.

Finally, this also makes `Buffer` use a bounded mpsc channel, which
introduces a new capacity argument to `Buffer::new`.

Fixes #110.
2018-11-19 09:30:45 -08:00
Sean McArthur 7dabd34d24
Tower Retry (#96)
- Inspect the request, response, and error when determining to retry
- Return a future if retry is desired
  - This future allows an impl to delay a retry
  - The future yields a new `Policy`, allowing state to be changed
    for later retries.
2018-08-28 11:05:15 -07:00
Oliver Gould 5e0a2c7e2f Introduce tower-watch (#87)
`tower_watch::WatchService` provides a dynamically-bound `Service` that
updates in response to a `Watch`. A `WatchService` is constructed with a
`Watch<T>` and a `Bind<T>` -- `Bind` is a newly introduced trait that
supports instantiating new service instances with a borrowed value, i.e.
from a watch.

This can be used to reconfigure Services from a shared or otherwise
externally-controlled configuration source (for instance, a file
system).
2018-07-11 15:03:20 -07:00
Carl Lerche 295ae583d4
Remove `ReadyService` (#68)
The value added by having a separate trait is not obvious. Equivalent
behavior can be provided by a `Service` implementation that is always
"ready".
2018-04-25 14:32:13 -07:00
Carl Lerche 5369879af6
Extract `Service` trait and related into crate. (#67)
This makes the `tower` crate available to be a "batteries included"
facade.
2018-04-25 12:35:52 -07:00
Brian Smith e0ca6545bb Upgrade to env_logger 0.5 and log 0.4 so that projects that use those (#52)
versions don't have to build both those versions and the older ones
that h2 is currently using.

Don't enable the regex support in env_logger. Applications that want
the regex support can enable it themselves; this will happen
automatically when they add their env_logger dependency.

Disable the env_logger dependency in quickcheck.

The result of this is that there are fewer dependencies. For example,
regex and its dependencies are no longer required at all, as can be
seen by observing the changes to the Cargo.lock. That said,
env_logger 0.5 does add more dependencies itself; however it seems
applications are going to use env_logger 0.5 anyway so this is still
a net gain.

Submitted on behalf of Buoyant, Inc.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-02-23 20:24:22 -08:00