-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 inclippyorrustcwould 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
AsyncReadvsStream<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...) -> RwhereRis anyRespondertype. Routes that do notawaitanything can remain unchanged.#[catch]ers can also be defined as anasync fn. - Methods on
Datanow returnFutures that must be.awaited. As a consequence, any route that usesDatadirectly must beasync. Routes that use data guards such asJsonare 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 (
FromTransformedDataandFromData,Fairing,Responder)- Several traits are now defined using
async-trait, re-exported as#[rocket::async_trait]. - Data is read asynchronously:
DataStreamimplementstokio::io::AsyncReadinstead ofRead. Thus,FromTransformedData::transformandFrom(Transformed)Data::from_dataareasync fnor returnFutures. - Response bodies are streamed to the client asynchronously:
set_bodyand related methods expecttokio::io::AsyncReadinstead ofRead.- Consequently,
Fairing::on_responseandResponder::respond_toare 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::asynchronousandrocket::local::blocking. Theblockingtest API is simpler to use, and recommended when possible. #[rocket::main],#[rocket::launch], and#[rocket::async_test]have been added to makeasync fneasily 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 .
jhpratt, vultix, gmorenz, JohnDoneth, sachaarbonel and 165 moreebkalderon, casey, marcelbuesing, flosse, pythoneer and 49 morecasey, flosse, pythoneer, viniciusd, NotIntMan and 46 morejhpratt, gmorenz, sachaarbonel, frol, gentoid and 50 moretbarusseau, chertov, sruffell, sharkguto, Type1J and 5 more
Metadata
Metadata
Assignees
Labels
No labels