Skip to content

Commit

Permalink
active-matches: Extract request interval as env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
raimannma committed Oct 10, 2024
1 parent ca348e7 commit d15921d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions active-matches-scraper/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
environment:
CACHE_FOLDER: /tmp
MATCHES_PER_FILE: 10000
REQUEST_INTERVAL: 21
volumes:
- tmp:/tmp
networks:
Expand Down
7 changes: 5 additions & 2 deletions active-matches-scraper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ use tokio::time::sleep;
mod rmq;
mod s3;

static REQUEST_INTERVAL: LazyLock<u64> =
LazyLock::new(|| std::env::var("REQUEST_INTERVAL").ok().and_then(|s| s.parse().ok()).unwrap_or(21));

static MATCHES_PER_FILE: LazyLock<usize> =
LazyLock::new(|| std::env::var("MATCHES_PER_FILE").unwrap().parse().unwrap());
LazyLock::new(|| std::env::var("MATCHES_PER_FILE").ok().and_then(|s| s.parse().ok()).unwrap_or(1000));

static CACHE_FOLDER: LazyLock<String> =
LazyLock::new(|| std::env::var("CACHE_FOLDER").unwrap_or("./tmp".to_string()));
Expand All @@ -22,7 +25,7 @@ static CACHE_FOLDER: LazyLock<String> =
async fn main() {
env_logger::init();

let interval = Duration::from_secs(20);
let interval = Duration::from_secs(*REQUEST_INTERVAL);
let mut active_matches: HashMap<u32, Vec<ActiveMatch>> = HashMap::new();

let parent_dir = std::path::Path::new(&*CACHE_FOLDER);
Expand Down

0 comments on commit d15921d

Please sign in to comment.