From e576c1ebde6a462656172d6c884c6b2f6aa58429 Mon Sep 17 00:00:00 2001 From: jstuczyn Date: Thu, 12 Nov 2020 16:55:08 +0000 Subject: [PATCH 1/2] Extra argument to specify metrics websocket + long attribute --- explorer/src/main.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/explorer/src/main.rs b/explorer/src/main.rs index 24df8945e0d..39969b9fd48 100644 --- a/explorer/src/main.rs +++ b/explorer/src/main.rs @@ -14,13 +14,22 @@ mod websockets; // this specifies number of messages that can be held by the channel, not number of the clients. const BROADCAST_CAPACITY: usize = 10; const VALIDATOR_ARG: &str = "validator"; +const METRICS_ARG: &str = "metrics"; fn parse_args<'a>() -> ArgMatches<'a> { App::new("Nym Explorer") .author("Nymtech") .arg( Arg::with_name(VALIDATOR_ARG) - .help("REST endpoint of the explorer will use to periodically grab topology and node status.") + .long(VALIDATOR_ARG) + .help("REST endpoint of the validator that explorer will use to periodically grab topology and node status.") + .takes_value(true) + .required(true), + ) + .arg( + Arg::with_name(METRICS_ARG) + .long(METRICS_ARG) + .help("websocket endpoint of the metrics server explorer will subscribe to and broadcast to its clients") .takes_value(true) .required(true), ) @@ -36,6 +45,7 @@ fn index() -> &'static str { async fn main() { let matches = parse_args(); let validator_base_url = matches.value_of(VALIDATOR_ARG).unwrap(); + let metrics_websocket_url = matches.value_of(METRICS_ARG).unwrap().to_owned(); tokio::task::spawn_blocking(|| { rocket::ignite() @@ -49,7 +59,7 @@ async fn main() { let sender_clone = sender.clone(); tokio::spawn(async move { - websockets::subscribe("wss://qa-metrics.nymtech.net/ws", sender).await; + websockets::subscribe(&*metrics_websocket_url, sender).await; }); tokio::spawn(async move { From 01c1cd8f7cf669cb80a51b730418831ac9be5e29 Mon Sep 17 00:00:00 2001 From: jstuczyn Date: Thu, 12 Nov 2020 17:29:41 +0000 Subject: [PATCH 2/2] Default testnet values --- explorer/src/main.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/explorer/src/main.rs b/explorer/src/main.rs index 39969b9fd48..60a841be082 100644 --- a/explorer/src/main.rs +++ b/explorer/src/main.rs @@ -24,14 +24,12 @@ fn parse_args<'a>() -> ArgMatches<'a> { .long(VALIDATOR_ARG) .help("REST endpoint of the validator that explorer will use to periodically grab topology and node status.") .takes_value(true) - .required(true), ) .arg( Arg::with_name(METRICS_ARG) .long(METRICS_ARG) .help("websocket endpoint of the metrics server explorer will subscribe to and broadcast to its clients") .takes_value(true) - .required(true), ) .get_matches() } @@ -44,8 +42,13 @@ fn index() -> &'static str { #[tokio::main] async fn main() { let matches = parse_args(); - let validator_base_url = matches.value_of(VALIDATOR_ARG).unwrap(); - let metrics_websocket_url = matches.value_of(METRICS_ARG).unwrap().to_owned(); + let validator_base_url = matches + .value_of(VALIDATOR_ARG) + .unwrap_or_else(|| "http://testnet-validator1.nymtech.net:8081"); + let metrics_websocket_url = matches + .value_of(METRICS_ARG) + .unwrap_or_else(|| "wss://testnet-metrics.nymtech.net/ws") + .to_owned(); tokio::task::spawn_blocking(|| { rocket::ignite()