Extra argument to specify metrics websocket + long attribute (#448)

* Extra argument to specify metrics websocket + long attribute

* Default testnet values
This commit is contained in:
Jędrzej Stuczyński
2020-11-12 17:31:16 +00:00
committed by GitHub
parent 830a89cfd4
commit 36ec2fef60
+17 -4
View File
@@ -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 {