Use concurrent uploads to aid performance

This commit is contained in:
Harrison Burt 2022-03-29 22:08:44 +01:00
parent c56242942e
commit 3a0e0ca0b5
1 changed files with 18 additions and 1 deletions

View File

@ -166,8 +166,25 @@ impl BucketController {
pipeline.on_fetch(desired_kind, retrieved_kind, data, sizing_id, custom_sizing)
}).await??;
let mut tasks = vec![];
for store_entry in result.result.to_store {
self.storage.store(self.bucket_id, image_id, store_entry.kind, store_entry.sizing_id, store_entry.data).await?;
let storage = self.storage.clone();
let bucket_id = self.bucket_id;
let t = tokio::spawn(async move {
storage.store(
bucket_id,
image_id,
store_entry.kind,
store_entry.sizing_id,
store_entry.data,
).await
});
tasks.push(t);
}
for task in tasks {
task.await??;
}
Ok(result.result.response)