I use actix-web and want to generate pairs of (password, password hash)
.
It takes some time (0.5s).
Instead of generating each pair on demand:
pub async fn signup (data: web::Data<AppData>) -> impl Responder {
// Generate password
let password = data.password_generator.generate_one().unwrap();
let password_hash = password::hash_encoded(password.as_bytes()); // 0.5s
// ...
}
I want to always have 10-20 of them pre-generated and just get already existing pair. After that generate a new one in the background.
How can I do it using actix-web?
I think of some kind of refilling "queue". But don't know how to implement it and use it correctly in multiple actix threads.