Skip to content

Commit e61c2c6

Browse files
committed
chore: remove cli arg and harcode const
1 parent df83f28 commit e61c2c6

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/cli.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use reqwest::Url;
2020

2121
use crate::{
2222
core::{AUTHOR_NAME, SERVICE_NAME},
23-
routing::{domain::CanisterAlias, RequestType},
23+
routing::{RequestType, domain::CanisterAlias},
2424
};
2525

2626
/// Clap does not support prefixes due to macro limitations.
@@ -320,9 +320,6 @@ pub struct Metrics {
320320
/// Where to listen for Prometheus metrics scraping
321321
#[clap(env, long)]
322322
pub metrics_listen: Option<SocketAddr>,
323-
/// How frequently to refresh statistics about API boundary nodes
324-
#[clap(env, long, default_value = "30s", value_parser = parse_duration)]
325-
pub api_boundary_nodes_stats_refresh_interval: Duration,
326323
}
327324

328325
#[derive(Args)]

src/routing/ic/route_provider.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use std::sync::Arc;
2-
use async_trait::async_trait;
1+
use std::{sync::Arc, time::Duration};
32
use anyhow::anyhow;
3+
use async_trait::async_trait;
44
use candid::Principal;
55
use ic_agent::agent::http_transport::reqwest_transport::reqwest::Client as AgentClient;
66
use ic_agent::agent::route_provider::{
@@ -21,6 +21,8 @@ use crate::routing::ic::{
2121
nodes_fetcher::{MAINNET_ROOT_SUBNET_ID, NodesFetcher},
2222
};
2323

24+
pub const API_BOUNDARY_NODES_STATS_REFRESH_INTERVAL: Duration = Duration::from_secs(30);
25+
2426
pub async fn setup_route_provider(
2527
urls: &[Url],
2628
ic_use_discovery: bool,
@@ -115,7 +117,9 @@ impl Run for ApiBoundaryNodesStats {
115117
async fn run(&self, _: CancellationToken) -> Result<(), anyhow::Error> {
116118
let stats = self.route_provider.routes_stats();
117119
self.metrics.total_nodes.set(stats.total as i64);
118-
self.metrics.healthy_nodes.set(stats.healthy.unwrap_or(0) as i64);
120+
self.metrics
121+
.healthy_nodes
122+
.set(stats.healthy.unwrap_or(0) as i64);
119123
Ok(())
120124
}
121125
}

src/routing/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use domain::{CustomDomainStorage, DomainResolver, ProvidesCustomDomains};
2121
use fqdn::FQDN;
2222
use http::{method::Method, uri::PathAndQuery, StatusCode, Uri};
2323
use ic_agent::agent::route_provider::RouteProvider;
24-
use ic::route_provider::ApiBoundaryNodesStats;
24+
use ic::route_provider::{ApiBoundaryNodesStats, API_BOUNDARY_NODES_STATS_REFRESH_INTERVAL};
2525
use ic_bn_lib::{
2626
http::{
2727
cache::{Cache, KeyExtractorUriRange, Opts},
@@ -322,7 +322,7 @@ pub fn setup_router(
322322
tasks.add_interval(
323323
"api_boundary_nodes_stats",
324324
Arc::new(ApiBoundaryNodesStats::new(route_provider.clone(), registry)),
325-
cli.metrics.api_boundary_nodes_stats_refresh_interval,
325+
API_BOUNDARY_NODES_STATS_REFRESH_INTERVAL,
326326
);
327327

328328
// Prepare the states

0 commit comments

Comments
 (0)