Commit Graph

45 Commits

Author SHA1 Message Date
Sean McArthur
7f5e853dd8 refactor(benches): make benchmark names more consistent 2021-11-12 15:09:52 -08:00
Sean McArthur
1b9af22fa0 Tokio 0.3 Upgrade (#2319)
Co-authored-by: Urhengulas <johann.hemmann@code.berlin>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-11-05 17:17:21 -08:00
Sean McArthur
f329ae0ff9 refactor(benches): add adaptive_window http2 benchmark 2020-03-30 16:28:58 -07:00
Sean McArthur
39a3bc0ea5 refactor(benches): change end_to_end response body default to empty 2020-03-30 16:13:46 -07:00
Sean McArthur
dd02254ae8 style(lib): apply latest rustfmt 2020-02-06 11:41:25 -08:00
danieleades
0eaf304644 style(lib): address most clippy lints 2020-01-03 09:40:32 -08:00
Sean McArthur
0dc89680cd style(lib): run rustfmt and enforce in CI 2019-12-05 13:55:17 -08:00
Sean McArthur
a738d03fd3 chore(dependencies): update to http-body 0.3 2019-12-04 16:48:06 -08:00
Sean McArthur
cb3f39c2dc feat(lib): update Tokio, bytes, http, h2, and http-body 2019-12-04 10:56:34 -08:00
Sean McArthur
5cb95bdda4 test(benches): add http2 chunks benchmark with default window size 2019-10-15 18:29:33 -07:00
Sean McArthur
51cdbea826 test(benches): add end-to-end chunked benchmarks 2019-10-15 18:05:57 -07:00
Sean McArthur
22695968d2 perf(http2): improve default HTTP2 flow control settings
Set default HTTP2 window sizes much larger values than the spec default.

ref #1960
2019-10-08 15:39:35 -07:00
Sean McArthur
049b5132db feat(client): change GaiResolver to use a global blocking threadpool
BREAKING CHANGE: Calls to `GaiResolver::new` and `HttpConnector::new` no
  longer should pass an integer argument for the number of threads.
2019-08-29 14:16:43 -07:00
lzutao
ae75b3a732 chore(lib): remove async_await feature gate (#1909)
`async_await` is stabilized in rust-lang/rust#63209.
2019-08-21 11:09:14 -07:00
Sean McArthur
a22dabd093 fix(server): change Builder window size methods to be by-value
Closes #1814
2019-08-20 17:45:01 -07:00
Sean McArthur
41f4173615 refactor(http2): re-enable http2 client and server support 2019-08-19 15:55:49 -07:00
Weihang Lo
74195bc17b test(end_to_end): ignore unimplemented h2 benchmarks
Signed-off-by: Weihang Lo <me@weihanglo.tw>
2019-07-23 10:53:03 -07:00
Weihang Lo
4f2abd81e8 test(benches): update end to end benchmark to async/await
Signed-off-by: Weihang Lo <me@weihanglo.tw>
2019-07-23 10:53:03 -07:00
Sean McArthur
5da17df97f chore(lib): individually disable tests and examples that aren't updated 2019-07-12 13:44:03 -07:00
Sean McArthur
da9b0319ef refactor(lib): update to 2018 edition 2019-07-09 15:16:01 -07:00
Sean McArthur
8b45af7f31 feat(server): add initial window builder methods that take self by-val (#1817)
The current `Builder` methods `http2_initial_stream_window_size` and
`http2_initial_connection_window_size` take `&mut self`, while every
other builder method takes `self`. That breaks up the chaining of
options.

This patch adds two methods that configure the same option, but take
`self` instead, and have an underscore suffix (so,
`http2_initial_stream_window_size_`).

cc #1814
2019-05-16 14:34:28 -07:00
Sean McArthur
973f981aa5 chore(benches): add a few parallel + body end-to-end configurations 2019-05-16 13:34:13 -07:00
Sean McArthur
fd25129dc0 perf(http1): implement an adaptive read buffer strategy
The default read strategy for HTTP/1 connections is now adaptive. It
increases or decreases the size of the read buffer depending on the
number of bytes that are received in a `read` call. If a transport
continuously fills the read buffer, it will continue to grow (up to the
`max_buf_size`), allowing for reading faster. If the transport
consistently only fills a portion of the read buffer, it will be shrunk.

This doesn't provide much benefit to small requests/responses, but
benchmarks show it to be a noticeable improvement to throughput when
streaming larger bodies.

Closes #1708
2018-11-28 12:54:17 -08:00
Sean McArthur
576addd531 test(benches): don't concat chunks, just drop them 2018-10-25 17:22:01 -07:00
Sean McArthur
79f970c7ff test(benches): clean up end_to_end benchmark configuration 2018-10-25 17:15:06 -07:00
Sean McArthur
b20971cb4e perf(http2): less eager server polls since it hurts parallel flushing 2018-10-24 15:35:11 -07:00
Sean McArthur
94e02ac276 perf(http2): eagerly poll some futures in h2 dispatchers before allocating in executor 2018-10-24 15:04:30 -07:00
Sean McArthur
e4ebf44823 chore(tests): change tests to use current_thread runtime 2018-06-18 12:30:56 -07:00
Sean McArthur
2dc6202fe7 feat(service): introduce hyper-specific Service
This introduces the `hyper::service` module, which replaces
`tokio-service`.

Since the trait is specific to hyper, its associated
types have been adjusted. It didn't make sense to need to define
`Service<Request=http::Request>`, since we already know the context is
HTTP. Instead, the request and response bodies are associated types now,
and slightly stricter bounds have been placed on `Error`.

The helpers `service_fn` and `service_fn_ok` should be sufficient for
now to ease creating `Service`s.

The `NewService` trait now allows service creation to also be
asynchronous.

These traits are similar to `tower` in nature, and possibly will be
replaced completely by it in the future. For now, hyper defining its own
allows the traits to have better context, and prevents breaking changes
in `tower` from affecting hyper.

Closes #1461

BREAKING CHANGE: The `Service` trait has changed: it has some changed
  associated types, and `call` is now bound to `&mut self`.

  The `NewService` trait has changed: it has some changed associated
  types, and `new_service` now returns a `Future`.

  `Client` no longer implements `Service` for now.

  `hyper::server::conn::Serve` now returns `Connecting` instead of
  `Connection`s, since `new_service` can now return a `Future`. The
  `Connecting` is a future wrapping the new service future, returning
  a `Connection` afterwards. In many cases, `Future::flatten` can be
  used.
2018-04-17 17:09:15 -07:00
Sean McArthur
c4974500ab feat(server): re-design Server as higher-level API
The `hyper::Server` is now a proper higher-level API for running HTTP
servers. There is a related `hyper::server::Builder` type, to construct
a `Server`. All other types (`Http`, `Serve`, etc) were moved into the
"lower-level" `hyper::server::conn` module.

The `Server` is a `Future` representing a listening HTTP server. Options
needed to build one are set on the `Builder`.

As `Server` is just a `Future`, it no longer owns a thread-blocking
executor, and can thus be run next to other servers, clients, or
what-have-you.

Closes #1322
Closes #1263

BREAKING CHANGE: The `Server` is no longer created from `Http::bind`,
  nor is it `run`. It is a `Future` that must be polled by an
  `Executor`.

  The `hyper::server::Http` type has move to
  `hyper::server::conn::Http`.
2018-04-16 14:29:19 -07:00
Sean McArthur
dfdca25c00 feat(body): rename Entity to Payload
Closes #1464
2018-04-10 15:55:23 -07:00
Sean McArthur
c210524e94 chore(tests): fix tokio runtime deprecations 2018-04-10 12:56:55 -07:00
Sean McArthur
625e4daaa1 Revert "refactor(lib): convert to futures 0.2.0-beta (#1470)"
This reverts commit a12f7beed9.

Much sadness 😢.
2018-04-10 12:56:55 -07:00
Sam Rijs
a12f7beed9 refactor(lib): convert to futures 0.2.0-beta (#1470) 2018-03-29 13:32:44 -07:00
Sam Reis
27b8db3af8 feat(lib): convert to use tokio 0.1
BREAKING CHANGE: All uses of `Handle` now need to be new-tokio `Handle`.

Co-authored-by: Sean McArthur <sean@seanmonstar.com>
2018-03-19 11:43:47 -07:00
Sean McArthur
3cd48b45fb feat(lib): replace types with those from http crate
BREAKING CHANGE: `Method`, `Request`, `Response`, `StatusCode`,
  `Version`, and `Uri` have been replaced with types from the `http`
  crate. The `hyper::header` module is gone for now.

  Removed `Client::get`, since it needed to construct a `Request<B>`
  with an empty body. Just use `Client::request` instead.

  Removed `compat` cargo feature, and `compat` related API.
2018-03-19 11:43:47 -07:00
Sean McArthur
1207c2b624 feat(client): introduce lower-level Connection API
Closes #1449
2018-03-07 14:26:52 -08:00
Sean McArthur
4de0de73be test(benches): fix deprecated futures usage in benches 2018-01-23 16:34:16 -08:00
Sean McArthur
50fd4ab96d chore(benches): remove unused pretty_env_logger import 2017-08-28 15:11:52 -07:00
Sean McArthur
4fb7e6ebc6 feat(lib): remove extern Url type usage
BREAKING CHANGE: The `Url` type is no longer used. Any instance in the
  `Client` API has had it replaced with `hyper::Uri`.

  This also means `Error::Uri` has changed types to
  `hyper::error::UriError`.

  The type `hyper::header::parsing::HTTP_VALUE` has been made private,
  as an implementation detail. The function `http_percent_encoding`
  should be used instead.
2017-03-21 11:03:57 -07:00
Sean McArthur
dc97dd77f4 feat(server): make Http default its body type to hyper::Chunk 2017-02-22 16:30:20 -08:00
Sean McArthur
1b1311a7d3 feat(http): allow specifying custom body streams 2017-02-16 15:06:55 -08:00
Alex Crichton
f45e9c8e4f refactor(server): expose Http that implements ServerProto
The main changes are:

* The entry point is how `Http`, the implementation of `ServerProto`.
  This type has a `new` constructor as well as builder methods to
  configure it.

* A high-level entry point of `Http::bind` was added which returns a
  `Server`. Binding a protocol to a port requires a socket address
  (where to bind) as well as the instance of `NewService`. Internally
  this creates a core and a TCP listener.

* The returned `Server` has a few methods to learn about itself, e.g.
  `local_addr` and `handle`, but mainly has two methods: `run` and
  `run_until`.

* The `Server::run` entry point will execute a server infinitely, never
  having it exit.

* The `Server::run_until` method is intended as a graceful shutdown
  mechanism. When the provided future resolves the server stops
  accepting connections immediately and then waits for a fixed period of
  time for all active connections to get torn down, after which the
  whole server is torn down anyway.

* Finally a `Http::bind_connection` method exists as a low-level entry
  point to spawning a server connection. This is used by `Server::run`
  as is intended for external use in other event loops if necessary or
  otherwise low-level needs.

BREAKING CHANGE: `Server` is no longer the pimary entry point. Instead,
  an `Http` type is created  and then either `bind` to receiver a `Server`,
  or it can be passed to other Tokio things.
2017-01-18 14:09:20 -08:00
Sean McArthur
be461b4663 perf(http): introduce MemBuf, a shared read buffer 2017-01-16 10:50:35 -08:00
Sean McArthur
2d2d5574a6 feat(lib): redesign API to use Futures and Tokio
There are many changes involved with this, but let's just talk about
user-facing changes.

- Creating a `Client` and `Server` now needs a Tokio `Core` event loop
to attach to.
- `Request` and `Response` both no longer implement the
`std::io::{Read,Write}` traits, but instead represent their bodies as a
`futures::Stream` of items, where each item is a `Chunk`.
- The `Client.request` method now takes a `Request`, instead of being
used as a builder, and returns a `Future` that resolves to `Response`.
- The `Handler` trait for servers is no more, and instead the Tokio
`Service` trait is used. This allows interoperability with generic
middleware.

BREAKING CHANGE: A big sweeping set of breaking changes.
2017-01-16 10:44:27 -08:00