Await in consumer

This commit is contained in:
Kitaiti Makoto 2022-05-05 04:51:42 +09:00
parent ce4b216722
commit f22c4d5c78

View File

@ -173,20 +173,21 @@ where
);
let client = client.clone();
let tx = tx.clone();
rt.spawn(async move {
let _ = tx.send(
rt.spawn(
client
.post(&inbox)
.headers(headers.clone())
.body(body)
.send()
.await,
.send(),
),
);
});
}
while let Some(request) = rx.recv().await {
let _ = request
.await
.map(move |r| {
r.map(|r| {
if r.status().is_success() {
debug!("Successfully sent activity to inbox ({})", &r.url());
} else {
@ -194,6 +195,7 @@ where
}
debug!("Response: \"{:?}\"\n", r);
})
})
.map_err(|e| warn!("Error while sending to inbox ({:?})", e));
}
});