KingOfCoders
KingOfCoders

Reputation: 2282

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?)

Upvotes: 0

Views: 1030

Answers (1)

kmdreko
kmdreko

Reputation: 59827

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

Upvotes: 2

Related Questions