Skip to content

Commit

Permalink
break out process_file for readability
Browse files Browse the repository at this point in the history
cargo fmt really does not like lots of code inside tokio::select! macros
  • Loading branch information
michaeldjeffrey committed Aug 27, 2024
1 parent 65e1f01 commit 504c6bc
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions mobile_packet_verifier/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,8 @@ where
let Some(file) = file else {
anyhow::bail!("FileInfoPoller sender was dropped unexpectedly");
};
tracing::info!("Verifying file: {}", file.file_info);
let ts = file.file_info.timestamp;
let mut transaction = self.pool.begin().await?;
let reports = file.into_stream(&mut transaction).await?;
crate::accumulate::accumulate_sessions(&self.gateway_info_resolver, &self.authorization_verifier, &mut transaction, &self.invalid_data_session_report_sink, ts, reports).await?;
transaction.commit().await?;
self.invalid_data_session_report_sink.commit().await?;

self.process_file(file).await?;
},
_ = sleep_until(burn_time) => {
// It's time to burn
Expand All @@ -112,6 +107,33 @@ where
}
}
}

async fn process_file(
&self,
file: FileInfoStream<DataTransferSessionIngestReport>,
) -> Result<()> {
tracing::info!("Verifying file: {}", file.file_info);

let ts = file.file_info.timestamp;
let mut transaction = self.pool.begin().await?;
let reports = file.into_stream(&mut transaction).await?;

accumulate_sessions(
&self.gateway_info_resolver,
&self.authorization_verifier,
&mut transaction,
&self.invalid_data_session_report_sink,
ts,
reports,
)
.await?;

transaction.commit().await?;
self.invalid_data_session_report_sink.commit().await?;
self.pending_data_session_report_sink.commit().await?;

Ok(())
}
}

#[derive(Debug, clap::Args)]
Expand Down

0 comments on commit 504c6bc

Please sign in to comment.