Skip to content

Commit

Permalink
Make pool reference arc
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Mar 21, 2024
1 parent d4a8dbe commit 0180273
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/maple/gtfs_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::error::Error;
// Removal of the attribution is not allowed, as covered under the AGPL license

// take a feed id and throw it into postgres
pub async fn gtfs_process_feed(feed_id: &str, pool: Arc<sqlx::Pool<sqlx::Postgres>>) -> Result<(), Box<dyn Error>> {
pub async fn gtfs_process_feed(feed_id: &str, pool: &Arc<sqlx::Pool<sqlx::Postgres>>) -> Result<(), Box<dyn Error>> {
let path = format!("gtfs_uncompressed/{}", feed_id);

let gtfs = gtfs_structures::Gtfs::new(path.as_str())?;
Expand Down
8 changes: 6 additions & 2 deletions src/maple/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,14 @@ async fn run_ingest() -> Result<(), Box<dyn Error>> {

let pool = Arc::new(pool);

rt.spawn(async move {
rt.spawn(
{
let pool = Arc::clone(&pool);
async move {
for (feed_id, _) in unzip_feeds.iter().filter(|unzipped_feed| unzipped_feed.1 == true) {
gtfs_process_feed(&feed_id, pool);
let gtfs_process_result = gtfs_process_feed(&feed_id, &pool).await;
}
}
});
}

Expand Down

0 comments on commit 0180273

Please sign in to comment.