Commit Graph

174 Commits

Author SHA1 Message Date
Carl Lerche bec3937e87
buffer: switch to TypedExecutor (#205) 2019-03-25 10:56:12 -07:00
Lucio Franco 0e70f1320e
layer: Add an identity layer (#195)
Tied to #175
2019-03-24 16:53:09 -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 5607313192
Minor `tower` crate re-org (#201)
- Rename `tower::ext` -> `tower::util`.
- Re-export structs from `tower-service-util` in `tower::util`.
- Re-export `tower_service::Service` at root.
2019-03-20 09:17:59 -07:00
Carl Lerche 263c680ea6 Remove tower-watch (#200) 2019-03-19 18:18:59 -07:00
Sean McArthur 1aba91313c
add poll_ready to MakeConnection (#202) 2019-03-19 18:18:07 -07:00
Carl Lerche 728f9d3c37
Fix fmt (#203) 2019-03-19 15:13:10 -07:00
Carl Lerche 733b597f38
Simplify Buffer::new error type
The returned error is now `Box<Error + Send + Sync>`.
2019-03-18 20:26:21 -07:00
Carl Lerche e05dc90340
Polish call all (#198)
- Move `CallAll` into `tower-service-util`
- Simplify error handling
- Add `CallAllUnordered`
2019-03-18 19:59:28 -07:00
Carl Lerche 92f4a0cb72
Rename tower-util -> tower (#197) 2019-03-15 10:53:19 -07:00
Carl Lerche fd54e47b56
rm tower-util/src/service_fn.rs (#196) 2019-03-14 19:51:50 -07:00
Carl Lerche f8d88427aa
discover: polish crate (#194) 2019-03-14 13:11:53 -07:00
Carl Lerche acda5a75b9
Initial introduction of tower-service-util (#193) 2019-03-14 11:27:36 -07:00
Carl Lerche 50fc5e8e63
Reorganize tower-timeout (#191)
- Change error bound: `Error: From<S::Error>` (for `?` operator)
- Split types into dedicated files
- Move `ResponseFuture` into public `future` mod.
2019-03-11 16:10:51 -07:00
Carl Lerche 720d31c65f
rate-limit: Refresh layout (#189)
- Switch to `Box<Error>`
- Break up lib.rs into multiple files.
- Use `tokio::clock::now` instead of `Instant::now`.
2019-03-08 22:44:48 -08:00
Sean McArthur 20102a647b
buffer: fix panics if worker executor drops unexpectedly (#190) 2019-03-08 18:18:01 -08:00
Jon Gjengset ac9488f5f2
Add a dynamically-sized load-balanced pool (#119)
This patch adds a new type, `Pool`, which wraps a
`tower_balance::Balance` and a `tower_service::NewService` together so
that new `Service` instances are added when load is high, and removed
again if load is low.

The pool uses an exponentially weighted moving average of successful
calls to `poll_ready` on the underlying `Balance` to estimate whether
there are enough services available. If `poll_ready` frequently returns
`NotReady`, then a new service is produced, whereas if `poll_ready`
pretty much never returns `NotReady`, the most recently added service is
removed from the pool (down to a minimum of 1).
2019-03-08 12:23:34 -05:00
Jon Gjengset 421fbf0006 Add CallAll combinator. (#187)
Add the `CallAll` combinator, which provides:

```rust
Stream<Item = Request> + Service<Request> => Stream<Item = Response>
```

That is, given a `Stream` of requests and a `Service` that can accept
those requests, it produces a `Stream` of the corresponding responses.
2019-03-08 09:19:38 -08:00
Carl Lerche e0d6d5b2f5
Refresh Reconnect (#185) 2019-03-08 08:46:12 -08:00
Sean McArthur 4c3742e41b
balance: update to Box<dyn Error> (#188) 2019-03-07 15:11:19 -08:00
Carl Lerche 1e38ee6e1f Fix in flight limit (#184)
* Move `InFlightLimitLayer` into `layer` mod

* Remove error type
2019-03-07 16:53:21 -05:00
Carl Lerche bdcce9677b
depend on tower-service from crates.io (#186) 2019-03-06 13:38:58 -08:00
Carl Lerche 794aa44c4b
Create subdir for tower crate (#182) 2019-03-06 07:54:39 -08:00
Carl Lerche fb01af2ad9
filter: Update error style (#178)
This patch does not migrate tower-filter to use an error type of
Box<Error>. Instead, it defines a new type that optionally contains
a Box<Error>.

The filter layer can be used as part of routing. The router would
sequentially attempt to dispatch a request to an inner service. If
the request is rejected, it attempts the next one. In this case, allocating
a Box<Error> for each attempt is not great.

This strategy still fits within the greater picture. tower_filter::error::Error
implements the error trait, which means that all other layers that take
T: Into<Error> will still work with Filter. Also, only the immediate caller
of Filter should care about rejection errors. In which case, Filter will be
referenced explicitly.

Refs: #131
2019-03-01 15:25:21 -08:00
Carl Lerche bf8c3b885a
mock: Use Box<Error> instead of a generic (#177)
Refs: #131
2019-03-01 13:56:57 -08:00
Carl Lerche 749e46b3f5
ci: `cd` into crate instead of `-p $crate` (#176)
Cargo is buggy when specifying the crate to run a command against.
2019-03-01 09:03:23 -08:00
Lucio Franco 0a234af4ba layer: Fix util feature and add chain try support (#174) 2019-02-28 14:34:00 -08:00
Carl Lerche 8bb8c2d48e
Try fixing doc deploy again (#173) 2019-02-28 14:25:41 -08:00
Carl Lerche cb67f5d6c3
Try fixing deploy docs (#172) 2019-02-28 12:20:55 -08:00
Carl Lerche de799582fb
Switch CI to Azure Pipelines (#171) 2019-02-28 12:08:29 -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
Sean McArthur 79a98ea05d timeout: update to Box<dyn Error> (#170) 2019-02-27 10:35:25 -08:00
Lucio Franco d874c251ff
timeout: Add derive Clone for the timeout service (#169) 2019-02-27 11:57:56 -05:00
Carl Lerche 8241fe8584
buffer: replace generic error with Box<Error> (#168)
Refs: #131
2019-02-26 13:40:16 -08:00
Carl Lerche 92653e68a6
Cleanup Buffer (#166)
* Move ResponseFuture, error types to dedicated mod
* Split code into multiple files.
* Remove `lazy_cell` dependency.
2019-02-25 10:01:26 -08:00
Stefano Probst a92a108239 Fix typo in Readme (#165) 2019-02-23 11:45:56 -05:00
Sean McArthur 0dc8281ef6
ext: add ServiceExt::oneshot to call the service when it is ready (#164) 2019-02-22 16:15:42 -08:00
Carl Lerche f42338934a
Require `poll_ready` to be called before `call` (#161)
This updates the `Service` contract requiring `poll_ready` to be called
before `call`. This allows `Service::call` to panic in the event the
user of the service omits `poll_ready` or does not wait until `Ready` is
observed.
2019-02-21 12:18:56 -08:00
Lucio Franco 79349816da service: Fix doc url attribute to point to the actual crate (#162) 2019-02-20 22:14:45 -08:00
Carl Lerche 25eb52153d
Remove DirectService (#160) 2019-02-16 10:21:59 -08:00
Jon Gjengset 8390a1d288 Remove DirectService from tower-{balance,buffer} (#159) 2019-02-15 14:52:00 -08:00
David Barsky d7e1b8f5dd Format tower with rustfmt; check in CI (#157) 2019-02-11 15:11:31 -08:00
Ty Coghlan 4c5ba67497 Update links in the README (#155)
Added tower-retry, removed tower-router.
2019-02-06 12:01:33 -08:00
Lucio Franco 61a183fe88 Add MakeConnection trait alias (#151) 2019-01-28 13:38:13 -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
Jon Gjengset 2d72bc8660 Switch tower-buffer to use tokio-sync (#152) 2019-01-28 11:23:03 -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 d42f48bbbb
Expose Service errors through tower-buffer (#143)
In the past, any errors thrown by a `Service` wrapped in a
`tower_buffer::Buffer` were silently swallowed, and the handles were
simply informed that the connection to the `Service` was closed.

This patch captures errors from a wrapped `Service`, and communicates
that error to all pending and future requests. It does so by wrapping up
the error in an `Arc`, which is sent to all pending `oneshot` request
channels, and is stored in a shared location so that future requests
will see the error when their send to the `Worker` fail.

Note that this patch also removes the `open` field from `State`, as it
is no longer necessary following #120, since bounded channels have a
`try_ready` method we can rely on instead.

Note that this change is not entirely backwards compatible -- the error
type for a `Service` that is wrapped in `Buffer` must now be `Send +
Sync` so that it can safely be communicated back to callers.
Furthermore, `tower_buffer::Error::Closed` now contains the error that
the failed `Service` produced, which may trip up old code.
2019-01-16 11:31:42 -05:00
Lucio Franco 9f422d29b1
Update the license for 2019 and tower contributors (#148) 2019-01-15 17:29:08 -05:00
David Barsky 68d3f6c22e
Use `tokio::timer` instead of `tokio_timer`; use Kind pattern (#141) 2019-01-15 15:05:14 -05:00