Commit Graph

349 Commits

Author SHA1 Message Date
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 793e2e8e94
Add a note about v0.3.x branch to the readme (#312)
* Add a note about v0.3.x branch to the readme

Signed-off-by: Lucio Franco <luciofranco14@gmail.com>

* Fix link

Signed-off-by: Lucio Franco <luciofranco14@gmail.com>
2019-08-20 23:20:01 -04:00
Lucio Franco 1351aaa9d8
service: Add changelog entry for 0.3.0-alpha.1 2019-08-20 14:34:30 -04:00
Lucio Franco fe9cef6006
Update `tower-service` to `std::future::Future` (#311) 2019-08-20 14:31:09 -04:00
Gabe Jackson b7faef31e9 docs: Minor typo + wording fixes (tower-util) (#309) 2019-08-19 10:13:56 -04:00
Gabe Jackson 168539ed9e docs: Minor typo + wording fixes (#310) 2019-08-17 17:10:17 -04:00
Lucio Franco 26d096bd99
timeout: Add `Elapsed::new` and prepare 0.1.1 release (#308)
* Add Elapsed::new

* Prep tower-timeout 0.1.1 release
2019-07-30 15:14:24 -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
Jon Gjengset 40fbb85c4b
Notify Pool when Services are dropped (#301)
Prior to this change, when `Balance` dropped a failing service, `Pool`
would not be notified of this fact. This meant that it never updated
`.services`, and so it might not add a new backing `Service` (e.g., due
to `max_services`) even though no working backing exist.

With this change, dropped services notify the `Pool` so that it knows to
re-check its limits. It also gains some much-needed tests.
2019-07-15 13:50:01 -04:00
Jon Gjengset 491dfbe634
Early push to bring tracing into tower (#298)
Of particular note is that this change lets spans trace requests through `tower::Buffer` by internally carrying the `Span` at the time of `call` along with the request to the worker.
2019-07-12 14:46:50 -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
Oliver Gould 18b30eb70e
balance: Only balance over ready endpoints (#293)
In 03ec4aa, the balancer was changed to make a quick endpoint decision.
This, however, means that the balancer can return NotReady when it does
in fact have a ready endpoint.

This changes the balancer to separate unready endpoints, only
performing p2c over ready endpoints. Unready endpoints are tracked with
a FuturesUnordered that supports eviction via oneshots.

The main downside of this change is that the Balancer must become
generic over the Request type.
2019-07-05 20:46:33 -07:00
Jon Gjengset 67a11f27ff
Fix some simple compile-time warnings (#297) 2019-07-05 17:10:11 -04:00
Oliver Gould 03ec4aafa8
balance: Specialize the balancer for P2C (#288)
As described in #286, `Balance` had a few problems:
- it is responsible for driving all inner services to readiness, making
  its `poll_ready` O(n) and not O(1);
- the `choose` abstraction was a hinderance. If a round-robin balancer
  is needed it can be implemented separately without much duplicate
  code; and
- endpoint errors were considered fatal to the balancer.

This changes replaces `Balance` with `p2c::Balance` and removes the
`choose` module.

Endpoint service failures now cause the service to be removed from the
balancer gracefully.

Endpoint selection is now effectively constant time, though it biases
for availability in the case when random selection does not yield an
available endpoint.

`tower-test` had to be updated so that a mocked service could fail after
advertising readiness.
2019-06-04 13:59:47 -07:00
Jon Gjengset 313530c875
Set a cap on the number of services in pool (#291)
This is very useful to avoid spinning up a million database connections for example (like I just did).
2019-05-31 15:12:01 -04:00
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