Commit Graph

334 Commits

Author SHA1 Message Date
Oliver Gould 82e7b8a27b
spawn-ready: Change layer to operate over MakeSpawnReady (#290)
The initial implementation of spawn-ready didn't properly compose over
MakeService instances. This introduces `MakeSpawnReady` as a factory
type for SpawnReady, and changes Layer to produce `MakeSpawnReady`
instances.
2019-05-30 12:07:08 -07: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 a611a14096
Fix tower-hedge tests and add to CI (#287)
Signed-off-by: Alex Leong <alex@buoyant.io>
2019-05-28 13:33:42 -07:00
Oliver Gould 9b27863a61
balance: Configure weights from keys, not services (#281)
* balance: Configure weights from keys, not services

The initial weighted balancing implementation required that the
underlying service implement `HasWeight`.

Practically, this doesn't work that well, since this may force
middlewares to implement this trait as well.

To fix this, we change the type bounds so that _keys_, not services,
must implement `HasWeight`.

This has a drawback, though, in that Weight, which contains a float,
cannot implement `Hash` or `Eq`, which is required by the balancer. This
tradeoff seems manageable, though (and is already addressed in linkerd,
for instance). We should follow-up with a change to alter the internal
representation of Weight to alleviate this.
2019-05-09 12:17:43 -07:00
Sean McArthur b9c2fea0fc Greatly improve Debug output of ServiceBuilder (#280) 2019-05-09 08:44:40 -07:00
Marcus Griep 4d6d2c8572 Minor docs fix (#277) 2019-04-29 13:50:47 -07:00
Carl Lerche 8a646dd25c
ci: fix isRelease condition (#274) 2019-04-27 09:32:40 -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 716bafd922
chore: fix small errors in Cargo files 2019-04-26 22:31:07 -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 a4c753bda6
retry: organize crate (#270)
This follows the idioms used by the other crates.
2019-04-24 15:24:39 -07:00
Carl Lerche 92a981f8d6
ensure `ResponseFuture` types are in `futures` mod (#269)
Follow the pattern used in the other crates.
2019-04-24 15:01:00 -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
Carl Lerche 4cb450fa1d
limit: rate::error should be private (#265) 2019-04-23 12:45:34 -07:00
Sean McArthur 484cbe7556 Remove `ServiceBuilder::make_service()` 2019-04-23 12:08:21 -07:00
Carl Lerche 91c8357db1
Remove tower/examples (#261)
The examples create a cyclical dependency between this repository and
tower-hyper. Examples are moved to https://github.com/tower-rs/examples.
2019-04-23 11:47:57 -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
Sean McArthur 27acbe600b impl Clone for Stack 2019-04-22 13:34:38 -07:00
Sean McArthur 5ec2979e83 impl Clone and Debug for Either 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 d8e6d6499b
buffer: make Buffer::new infallible (#257)
Creating a buffer can internally fail to spawn a worker. Before, that
error was returned immediately from `Buffer::new`. This changes `new` to
always return a `Buffer`, and the spawn error is encountered via
`poll_ready`.
2019-04-22 13:06:20 -07:00
João Oliveira cc58745952 update doc examples (#259) 2019-04-22 10:55:14 -07:00
Alex Leong e15d49903a
Pin tower-hyper dep to a specific revision (#258)
Signed-off-by: Alex Leong <alex@buoyant.io>
2019-04-19 15:48:31 -07:00
Sean McArthur 979c139912 MakeConnection: rename Request generic to Target (#250) 2019-04-10 15:11:11 -07:00
Sean McArthur 2a3a577929 change ServiceFn to use FnMut instead of Fn (#249) 2019-04-10 13:37:00 -07:00
Sean McArthur d1c891d1ba
Promote service_fn to tower crate (#248) 2019-04-10 13:17:16 -07:00
Lucio Franco 23ce9133b5 buffer: Move buffer to service.rs and layer to layer.rs (#246) 2019-04-10 12:35:05 -07:00
Sean McArthur 1012b20737
util: derive Clone for ServiceFn (#245) 2019-04-10 12:02:15 -07:00
Carl Lerche 0f58e50c3d
Rename `Chain` -> `Stack` (#239)
Reduce metaphors.

Fixes #233
2019-04-09 13:09:44 -07:00
Jake Shadle b42a365828 Add license field to all crates (#241) 2019-04-09 10:59:30 -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 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 5ed014fc37
ci: include missing crates in CI run (#231) 2019-04-04 12:37:07 -07:00
Carl Lerche 971bb06152
Provide layer specific fns on `ServiceBuilder` (#227) 2019-04-03 20:40:06 -07:00
Oliver Gould aa8d024fc9
Support weighted balancing (#221)
In order to implement red-line testing, blue-green deployments, and
other operational use cases, many service discovery and routing schemes
support endpoint weighting.

In this iteration, we provide a decorator type, `WeightedLoad`, that may
be used to wrap load-bearing services to alter their load according to a
weight.  The `WithWeighted` type may also be used to wrap `Discover`
implementations, in which case it will wrap all new services with
`WeightedLoad`.
2019-04-03 19:59:46 -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
Lucio Franco 1fb42357f9
retry: Call poll_ready on the inner service (#223)
mock: Panic if poll_ready is not called
2019-04-02 17:53:24 -04:00
Carl Lerche d7516c3222
balance: minor cleanup (#220) 2019-03-29 19:17:21 -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 3fd5b581cc
Fix build. (#217)
A recently merged PR failed to track master.
2019-03-29 14:39:34 -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
Carl Lerche 2448ca9cdc
balance: cleanup example (#211) 2019-03-29 14:24:43 -07:00