rustrust-tokioactix-webrust-actix

How to do write-behind async tasks in Actix-Web?


In a web environment with Actix-Web I want to write behind data to a database, async so the request is not held up. This could also be calling a webhook or calling an API to send an email.

With Scala I would create a queue and use a thread pool (e.g. with ForkJoin) to fire and forget a task.

How would I do this in Rust with Actix-Web? (Actix actors?)


Solution

  • You would use actix_web::rt::spawn to execute an async function that runs independently.