Use driver url from configuration

This commit is contained in:
Kienan Stewart 2022-09-24 10:34:26 -04:00
parent 6c0e022f7a
commit 053910c03f
1 changed files with 4 additions and 4 deletions

View File

@ -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());