Skip to content

Commit 36ec2fe

Browse files
authored
Extra argument to specify metrics websocket + long attribute (#448)
* Extra argument to specify metrics websocket + long attribute * Default testnet values
1 parent 830a89c commit 36ec2fe

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

explorer/src/main.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,22 @@ mod websockets;
1414
// this specifies number of messages that can be held by the channel, not number of the clients.
1515
const BROADCAST_CAPACITY: usize = 10;
1616
const VALIDATOR_ARG: &str = "validator";
17+
const METRICS_ARG: &str = "metrics";
1718

1819
fn parse_args<'a>() -> ArgMatches<'a> {
1920
App::new("Nym Explorer")
2021
.author("Nymtech")
2122
.arg(
2223
Arg::with_name(VALIDATOR_ARG)
23-
.help("REST endpoint of the explorer will use to periodically grab topology and node status.")
24+
.long(VALIDATOR_ARG)
25+
.help("REST endpoint of the validator that explorer will use to periodically grab topology and node status.")
26+
.takes_value(true)
27+
)
28+
.arg(
29+
Arg::with_name(METRICS_ARG)
30+
.long(METRICS_ARG)
31+
.help("websocket endpoint of the metrics server explorer will subscribe to and broadcast to its clients")
2432
.takes_value(true)
25-
.required(true),
2633
)
2734
.get_matches()
2835
}
@@ -35,7 +42,13 @@ fn index() -> &'static str {
3542
#[tokio::main]
3643
async fn main() {
3744
let matches = parse_args();
38-
let validator_base_url = matches.value_of(VALIDATOR_ARG).unwrap();
45+
let validator_base_url = matches
46+
.value_of(VALIDATOR_ARG)
47+
.unwrap_or_else(|| "http://testnet-validator1.nymtech.net:8081");
48+
let metrics_websocket_url = matches
49+
.value_of(METRICS_ARG)
50+
.unwrap_or_else(|| "wss://testnet-metrics.nymtech.net/ws")
51+
.to_owned();
3952

4053
let public_path = std::env::current_exe()
4154
.expect("Failed to evaluate current exe path")
@@ -55,7 +68,7 @@ async fn main() {
5568
let sender_clone = sender.clone();
5669

5770
tokio::spawn(async move {
58-
websockets::subscribe("wss://qa-metrics.nymtech.net/ws", sender).await;
71+
websockets::subscribe(&*metrics_websocket_url, sender).await;
5972
});
6073

6174
tokio::spawn(async move {

0 commit comments

Comments
 (0)