-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return a Future from app.serve #163
Comments
Within the bounds of this proposal, is it possible to still provide a "batteries-included" runtime experience for new users? |
@secretfader you could have it return a custom future, that then as a function on it call say |
I agree with this proposal. Currently, it is a challenge to set up an asynchronous database pool with Tide, as you can't use the same runtime as Tide. |
With Runtime we'll be able to also get rid of most of the boilerplate this change would introduce 😊 : #![feature(async_await)]
#[runtime::main(runtime_tokio::Tokio)]
async fn main() -> Result<(), failure::Error> {
let mut app = tide::App::new(());
app.at("/").get(async move |_| "Hello, world!");
await!(app.serve("127.0.0.1:8000"))?;
} |
I'm working on this, the update on |
Closed via #203 |
Feature Request
Detailed Description
Instead of creating a runtime inside
app.serve
, I propose we return a future instead that allows people to run the app on whichever runtime they choose.Context
From the API it currently isn't clear that Tide operates asynchronously. Also things like starting a database in parallel to Tide feels a bit awkward because async control flow primitives such as
try_join
andselect
don't work.I propose we move from this:
To this:
We then shift the problem to making
my_runtime::run
nicer to use, but that's something that's worth solving for the whole async ecosystem, and not just Tide.Possible Implementation
We would need to patch this line: https://github.com/rustasync/http-service/blob/master/http-service-hyper/src/lib.rs#L94, and propagate it through to Tide.
The text was updated successfully, but these errors were encountered: