Skip to content

Commit

Permalink
Merge pull request #17 from nrdxp/fns-remove-hack
Browse files Browse the repository at this point in the history
fns: remove hack; limit async closure capture to zone->id
  • Loading branch information
nrdxp authored Sep 18, 2023
2 parents a52263c + f862d36 commit f267df8
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/fns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,18 @@ pub async fn get_records(
let params = ListZones {
params: ListZonesParams::default(),
};
let zones = client.request(&params);
// HACK: make a second call since dns::Zone does not implement Clone upstream
let zones2 = client.request(&params).await?.result;
let zones = client.request(&params).await?.result;

let mut handles = Vec::with_capacity(zones2.len());
let mut records = Vec::with_capacity(zones2.len() * 10);
let mut handles = Vec::with_capacity(zones.len());
let mut records = Vec::with_capacity(zones.len() * 10);

for zone in zones.await?.result {
for zone in &zones {
let client = client.clone();
let zone_id = zone.id.to_string();
handles.push(tokio::spawn(async move {
client
.request(&ListDnsRecords {
zone_identifier: &zone.id,
zone_identifier: &zone_id,
params: ListDnsRecordsParams::default(),
})
.await
Expand Down Expand Up @@ -117,7 +116,7 @@ pub async fn get_records(
.map(|r| {
(
r.to_owned(),
zones2
zones
.iter()
.find(|z| r.contains(&z.name))
.map(|z| z.id.to_owned()),
Expand Down

0 comments on commit f267df8

Please sign in to comment.