From 36ec2fef60b29cd903c76319bdf8bf2aac694a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Thu, 12 Nov 2020 17:31:16 +0000 Subject: [PATCH] Extra argument to specify metrics websocket + long attribute (#448) * Extra argument to specify metrics websocket + long attribute * Default testnet values --- explorer/src/main.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/explorer/src/main.rs b/explorer/src/main.rs index 475e84587b..1fdfb9e234 100644 --- a/explorer/src/main.rs +++ b/explorer/src/main.rs @@ -14,15 +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) + ) + .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() } @@ -35,7 +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 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(); let public_path = std::env::current_exe() .expect("Failed to evaluate current exe path") @@ -55,7 +68,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 {