Make Storage methods async

This will better support concurrent requests.
This commit is contained in:
Dustin J. Mitchell
2025-07-11 17:28:05 -04:00
parent 4de5c9a345
commit 7559364017
13 changed files with 597 additions and 412 deletions

View File

@ -49,6 +49,7 @@ pub(crate) async fn service(
server_state
.server
.add_snapshot(client_id, version_id, body.to_vec())
.await
.map_err(server_error_to_actix)?;
Ok(HttpResponse::Ok().body(""))
}
@ -70,10 +71,10 @@ mod test {
// set up the storage contents..
{
let mut txn = storage.txn(client_id).unwrap();
txn.new_client(version_id).unwrap();
txn.add_version(version_id, NIL_VERSION_ID, vec![])?;
txn.commit()?;
let mut txn = storage.txn(client_id).await.unwrap();
txn.new_client(version_id).await.unwrap();
txn.add_version(version_id, NIL_VERSION_ID, vec![]).await?;
txn.commit().await?;
}
let server = WebServer::new(Default::default(), None, storage);
@ -114,9 +115,9 @@ mod test {
// set up the storage contents..
{
let mut txn = storage.txn(client_id).unwrap();
txn.new_client(NIL_VERSION_ID).unwrap();
txn.commit().unwrap();
let mut txn = storage.txn(client_id).await.unwrap();
txn.new_client(NIL_VERSION_ID).await.unwrap();
txn.commit().await.unwrap();
}
let server = WebServer::new(Default::default(), None, storage);