Closed
Description
Status
Rocket's master
branch is currently fully asynchronous and supports async/await!
Pending
- (async) Remove or replace typed headers #1067 - Remove or replace typed headers (PR: Fix #1067 by importing typed headers from hyperx #1535)
- Fully update documentation for 0.5 #1329 - Documentation fixes, additions, improvements.
- Provide a lower-level connection interface #1070 - Expose APIs for customizing the underlying I/O, instead of being restricted to TCP with optional TLS.
- Detect blocking I/O in async: it seems the best we can do for now is to document the issues.
A "blocking-in-async" lint inclippy
orrustc
would be much nicer, if feasible, but would occur upstream...someday. - Miscellaneous small TODOs (tagged as
TODO.async
) throughout code. - Response bodies are passed back to hyper using a channel.
Done
- Async I/O everything!
- Harden and Enforce Data Read Limits #1325 - Data reading and connection limits.
- Keep-alive and idle client timeouts
- Handling of blocking database connections.
- Gracefully handle panics with 500. (PR Catch and gracefully handle panics in routes and catchers. #1491)
- (async) Add a Write-like interface for responses #1066 - Add a Write-like interface for responses, and consideration of
AsyncRead
vsStream<Item=Result<Chunk, Error>>
- Clean shutdown? #180, Graceful shutdown timeout #1374 - fixing graceful shutdown when using "infinite" responders
- Support for Server Sent Events #33 - Server-Sent Events
- Tracking Issue for Asynchronous Database Pool Support #1117 - Asynchronous database pools, or at the very least forward compatibility with them.
Design
The async
APIs are based on rust's async/await feature and std::future::Future
, running on the tokio
(0.2) runtime.
- High-level APIs (routes and catchers):
- Routes can now be defined as
#[get|post|route(...)] async fn(params...) -> R
whereR
is anyResponder
type. Routes that do notawait
anything can remain unchanged.#[catch]
ers can also be defined as anasync fn
. - Methods on
Data
now returnFuture
s that must be.await
ed. As a consequence, any route that usesData
directly must beasync
. Routes that use data guards such asJson
are not affected by this change. - Routes that make their own network requests or other I/O should be
async
, as it will allow other requests to continue while waiting for the operation.
- Routes can now be defined as
- Mid and low-level APIs (
FromTransformedData
andFromData
,Fairing
,Responder
)- Several traits are now defined using
async-trait
, re-exported as#[rocket::async_trait]
. - Data is read asynchronously:
DataStream
implementstokio::io::AsyncRead
instead ofRead
. Thus,FromTransformedData::transform
andFrom(Transformed)Data::from_data
areasync fn
or returnFuture
s. - Response bodies are streamed to the client asynchronously:
set_body
and related methods expecttokio::io::AsyncRead
instead ofRead
.- Consequently,
Fairing::on_response
andResponder::respond_to
are nowasync fn
. This allows Responders and Fairings to access and/or replace the body data.
- Consequently,
- Several traits are now defined using
- The testing APIs have been moved to
rocket::local::asynchronous
androcket::local::blocking
. Theblocking
test API is simpler to use, and recommended when possible. #[rocket::main]
,#[rocket::launch]
, and#[rocket::async_test]
have been added to makeasync fn
easily accessible formain()
andtest()
.- Many long-standing bugs with keep-alive, graceful shutdown (Clean shutdown? #180), performance, and more are fixed or will be easier to fix by using actively-supported versions of libraries.
- Some new functionality will be possible to implement, such as SSE and WebSockets. These will likely not make it into Rocket 0.5. At this point, Rocket should not be missing any APIs necessary to implement SSE "by hand". WebSockets is a bit more complicated, and tracked in Native WebSocket support #90 .
Metadata
Metadata
Assignees
Labels
No labels