Commit e25fb23d authored by Mike Cronce's avatar Mike Cronce

src/main.rs: Made poll_character async and put the call to Profile::get() in a blocking task

parent 645fc061
......@@ -28,9 +28,9 @@ struct Config {
character_ids: character_ids::CharacterIDs
}
fn poll_character(id: u32) -> Result<Vec<WriteQuery>, Box<dyn Error>> {
async fn poll_character(id: u32) -> Result<Vec<WriteQuery>, Box<dyn Error>> {
let now = Utc::now();
let profile = lodestone::model::profile::Profile::get(id)?;
let profile = tokio::task::spawn_blocking(move || lodestone::model::profile::Profile::get(id)).await??;
match &profile.free_company {
Some(v) => println!("{} on {}, in {}", profile.name, profile.server, v),
None => println!("{} on {}", profile.name, profile.server)
......@@ -72,7 +72,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
let client = influxdb_config::client_from_env().unwrap();
let mut config = Config::init().unwrap();
for id in config.character_ids.iter() {
let queries = match poll_character(*id) {
let queries = match poll_character(*id).await {
Err(e) => {
eprintln!("poll fail: {:?}", e);
Vec::new()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment