Skip to content

Commit

Permalink
Mapping to delete subscription futures instead of pushing to vec.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmackdev committed Sep 16, 2023
1 parent af60fae commit 630fa99
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pubsubman_backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,16 @@ impl Backend {
let client = self.client.clone();

rt.spawn(async move {
let mut futures = vec![];

for sub_name in sub_names.into_iter() {
let futures = sub_names.into_iter().map(|sub_name| {
let client = client.clone();
futures.push(async move {
async move {
let subscription = client.subscription(&sub_name.0);
match subscription.delete(None).await {
Ok(_) => Ok(sub_name),
Err(_) => Err(sub_name),
}
});
}
}
});

let results = futures::future::join_all(futures).await;

Expand Down

0 comments on commit 630fa99

Please sign in to comment.