Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra argument to specify metrics websocket + long attribute #448

Merged
merged 2 commits into from
Nov 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions explorer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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();

tokio::task::spawn_blocking(|| {
rocket::ignite()
Expand All @@ -49,7 +62,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 {
Expand Down