fixed critical stall bug on first card
This commit is contained in:
parent
aa4559be2a
commit
6cd610e727
3 changed files with 11 additions and 13 deletions
12
src/cards.rs
12
src/cards.rs
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use reqwest;
|
use reqwest;
|
||||||
use prometheus::{GaugeVec, Opts};
|
use prometheus::{GaugeVec, Opts, Registry};
|
||||||
use std::{env, fs::File, fs::OpenOptions, io::BufReader, collections::HashMap};
|
use std::{env, fs::File, fs::OpenOptions, io::BufReader, collections::HashMap,sync::Arc};
|
||||||
use crate::util;
|
use crate::util;
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
|
|
@ -88,8 +88,8 @@ pub async fn process_cards(interval: &mut tokio::time::Interval) -> Result<(), B
|
||||||
for card_from_file in &mut cards_data.cards {
|
for card_from_file in &mut cards_data.cards {
|
||||||
process_card(card_from_file).await?;
|
process_card(card_from_file).await?;
|
||||||
pb.inc(1);
|
pb.inc(1);
|
||||||
interval.tick().await;
|
|
||||||
}
|
}
|
||||||
|
interval.tick().await;
|
||||||
|
|
||||||
process_export_data(&mut cards_data.cards);
|
process_export_data(&mut cards_data.cards);
|
||||||
pb.finish_with_message("Completed!");
|
pb.finish_with_message("Completed!");
|
||||||
|
|
@ -102,3 +102,9 @@ pub async fn process_cards(interval: &mut tokio::time::Interval) -> Result<(), B
|
||||||
serde_json::to_writer_pretty(file, &cards_data)?;
|
serde_json::to_writer_pretty(file, &cards_data)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn setup_registry() -> Result<Arc<Registry>, Box<dyn std::error::Error>> {
|
||||||
|
let registry = Arc::new(Registry::new());
|
||||||
|
registry.register(Box::new(CARD_VALUES.clone())).unwrap();
|
||||||
|
Ok(registry)
|
||||||
|
}
|
||||||
10
src/main.rs
10
src/main.rs
|
|
@ -1,8 +1,6 @@
|
||||||
use dotenv;
|
use dotenv;
|
||||||
use tokio::time::Duration;
|
use tokio::time::Duration;
|
||||||
use prometheus::Registry;
|
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
mod server;
|
mod server;
|
||||||
mod cards;
|
mod cards;
|
||||||
|
|
@ -11,7 +9,7 @@ mod handlers;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
use server::run_server;
|
use server::run_server;
|
||||||
use cards::{CARD_VALUES,get_data_update_interval};
|
use cards::{setup_registry, get_data_update_interval};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
@ -33,9 +31,3 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
cards::process_cards(&mut interval).await?;
|
cards::process_cards(&mut interval).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_registry() -> Result<Arc<Registry>, Box<dyn std::error::Error>> {
|
|
||||||
let registry = Arc::new(Registry::new());
|
|
||||||
registry.register(Box::new(CARD_VALUES.clone())).unwrap();
|
|
||||||
Ok(registry)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ pub fn setup_progress_bar(len: u64) -> ProgressBar {
|
||||||
let style = ProgressStyle::default_bar()
|
let style = ProgressStyle::default_bar()
|
||||||
.template("{spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {pos}/{len} ({eta})")
|
.template("{spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {pos}/{len} ({eta})")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.progress_chars("#|.");
|
.progress_chars("#>.");
|
||||||
pb.set_style(style);
|
pb.set_style(style);
|
||||||
pb
|
pb
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue