From 053910c03f749f8d7c7ecf08d7a45a6ebfab8803 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Sat, 24 Sep 2022 10:34:26 -0400 Subject: [PATCH] Use driver url from configuration --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index a70b9b1..096bb37 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,5 @@ use std::cmp::Ordering; use std::env; -use std::str::FromStr; use std::thread; use std::time::Duration; use std::time::Instant; @@ -58,7 +57,6 @@ fn main() { } } - let driver = "http://localhost:4444"; let mut jobs = Vec::new(); let some_job = Job { url: "https://www.rust-lang.org", @@ -130,8 +128,10 @@ fn main() { for tj in jobs.iter_mut() { let should_run_by_time = tj.job.last_run.is_some() && Instant::now().duration_since(tj.job.last_run.unwrap()).ge(&tj.job.every); if tj.handle.is_none() && (should_run_by_time || tj.job.last_run.is_none()) { - tj.handle = Some(thread::spawn(|| { - return get_source(driver, tj.job.url); + let driver = conf.driver_url.clone(); + let url = tj.job.url.clone(); + tj.handle = Some(thread::spawn(move || { + return get_source(driver.as_str(), url); })); println!("Started thread for '{}'", tj.job.url); tj.job.last_run = Some(Instant::now());