My application currently looks like this:
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let abc = prepare_foobar().await;
// ...
// HttpServer::new()?
}
Is it possible to start the HTTP server within my existing runtime context?
actix supports current-thread runtime, tokio starts multithreaded ru time by default
I might have misunderstood, but looks like #[tokio::main(basic_scheduler)] also does not work.
Is there a guide or example that demonstrates how to use Tokio-based libraries from within an actix-web server?
From the actix-rt docs, it seems like you can create a system that uses Tokio under the hood. But it is not clear how to use this to start an actix-web server.
let rt = tokio::runtime::Runtime::new().unwrap();
let system = actix_rt::System::run_in_tokio("test", rt.handle());
???
Thanks.
@fafhrd91 the complete lack of support for tokio doesn't look good for actix-web.
@mpfaff fafhrd91 doesnt work on actix anymore.
What are you needing to do specifically.
@robjtede my apologies. I need to use actix (or some other http server) as one component of many running simultaneously in the same program. I thought I would be able to do that by starting each component as an asynchronous task.
Most helpful comment
I might have misunderstood, but looks like
#[tokio::main(basic_scheduler)]also does not work.Is there a guide or example that demonstrates how to use Tokio-based libraries from within an actix-web server?
From the
actix-rtdocs, it seems like you can create a system that uses Tokio under the hood. But it is not clear how to use this to start anactix-webserver.Thanks.