feat: Improve concurrency

This commit is contained in:
2026-10-04 05:39:18 +02:00
parent bcf716038e
commit 63c014fd3f
3 changed files with 54 additions and 31 deletions
+12 -13
View File
@@ -29,21 +29,20 @@ where
// We can't use async directly inside a custom deserializer, and using the blocking client also
// does not work as it will try to start tokio inside of tokio.
// So we have do this to work around it.
let response = tokio::task::block_in_place(|| {
Handle::current().block_on(async {
let res = client
.post("https://factory.talos.dev/schematics")
.body(content)
.send()
.await
// NOTE: This requires that the deserialization happens inside spawn_blocking
let response = Handle::current().block_on(async {
let res = client
.post("https://factory.talos.dev/schematics")
.body(content)
.send()
.await
.map_err(serde::de::Error::custom)?;
let response: Response =
serde_json::from_str(&res.text().await.map_err(serde::de::Error::custom)?)
.map_err(serde::de::Error::custom)?;
let response: Response =
serde_json::from_str(&res.text().await.map_err(serde::de::Error::custom)?)
.map_err(serde::de::Error::custom)?;
Ok(response)
})
Ok(response)
})?;
Ok(response.id)