Skip to content

Commit b9ea9f5

Browse files
committed
chore: Introduce configurable fetch interval for match history
1 parent 395d41d commit b9ea9f5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

history-fetcher/src/main.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
mod types;
1515

1616
use core::time::Duration;
17-
17+
use std::sync::LazyLock;
1818
use metrics::{counter, gauge};
1919
use tracing::{debug, error, info, instrument};
2020
use valveprotos::deadlock::c_msg_client_to_gc_get_match_history_response::EResult;
@@ -24,6 +24,12 @@ use valveprotos::deadlock::{
2424

2525
use crate::types::PlayerMatchHistoryEntry;
2626

27+
static FETCH_INTERVAL_MILLIS: LazyLock<u64> = LazyLock::new(|| {
28+
std::env::var("FETCH_INTERVAL_MILLIS")
29+
.map(|x| x.parse().expect("FETCH_INTERVAL_MILLIS must be a number"))
30+
.unwrap_or(10_000)
31+
});
32+
2733
#[tokio::main]
2834
async fn main() -> anyhow::Result<()> {
2935
common::init_tracing();
@@ -32,7 +38,7 @@ async fn main() -> anyhow::Result<()> {
3238
let http_client = reqwest::Client::new();
3339
let ch_client = common::get_ch_client()?;
3440

35-
let mut interval = tokio::time::interval(Duration::from_secs(8));
41+
let mut interval = tokio::time::interval(Duration::from_millis(*FETCH_INTERVAL_MILLIS));
3642

3743
loop {
3844
let accounts = match fetch_accounts(&ch_client).await {

0 commit comments

Comments
 (0)