feat(scheduled_tasks): update for k8s (#734)

This commit is contained in:
skye 2025-05-03 06:21:39 -04:00 committed by GitHub
parent 94a3276979
commit 7cff9abee3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 8 deletions

View file

@ -92,12 +92,14 @@ pub async fn update_discord_stats(ctx: AppCtx) -> anyhow::Result<()> {
let mut guild_count = 0;
let mut channel_count = 0;
let mut url = cfg.gateway_url.clone();
for idx in 0..cfg.expected_gateway_count {
let res = client
.get(format!("http://cluster{idx}.{}/stats", cfg.gateway_url))
.send()
.await?;
if url.contains("{clusterid}") {
url = url.replace("{clusterid}", &idx.to_string());
}
let res = client.get(&url).send().await?;
let stat: GatewayStatus = res.json().await?;
@ -163,6 +165,11 @@ pub async fn update_stats_api(ctx: AppCtx) -> anyhow::Result<()> {
.build()
.expect("error making client");
let cfg = config
.scheduled_tasks
.as_ref()
.expect("missing scheduled_tasks config");
#[derive(serde::Deserialize, Debug)]
struct PrometheusResult {
data: PrometheusResultData,
@ -178,11 +185,9 @@ pub async fn update_stats_api(ctx: AppCtx) -> anyhow::Result<()> {
macro_rules! prom_instant_query {
($t:ty, $q:expr) => {{
tracing::info!("Query: {}", $q);
let resp = client
.get(format!(
"http://vm.svc.pluralkit.net/select/0/prometheus/api/v1/query?query={}",
$q
))
.get(format!("{}/api/v1/query?query={}", cfg.prometheus_url, $q))
.send()
.await?;