mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Prometheus options in Substrate relay (#402)
This commit is contained in:
committed by
Bastian Köcher
parent
86834e2fd6
commit
ddeb59d336
@@ -12,7 +12,6 @@ codec = { package = "parity-scale-codec", version = "1.3.4" }
|
||||
futures = "0.3.5"
|
||||
log = "0.4.11"
|
||||
paste = "1.0"
|
||||
sp-runtime = "2.0"
|
||||
structopt = "0.3"
|
||||
|
||||
# Bridge dependencies
|
||||
@@ -24,3 +23,7 @@ relay-millau-client = { path = "../millau-client" }
|
||||
relay-rialto-client = { path = "../rialto-client" }
|
||||
relay-substrate-client = { path = "../substrate-client" }
|
||||
relay-utils = { path = "../utils" }
|
||||
|
||||
# Substrate dependencies
|
||||
|
||||
sp-runtime = "2.0"
|
||||
|
||||
@@ -27,6 +27,7 @@ pub fn parse_args() -> Command {
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(about = "Substrate-to-Substrate relay")]
|
||||
pub enum Command {
|
||||
/// Relay Millau headers to Rialto.
|
||||
MillauHeadersToRialto {
|
||||
#[structopt(flatten)]
|
||||
millau: MillauConnectionParams,
|
||||
@@ -34,9 +35,38 @@ pub enum Command {
|
||||
rialto: RialtoConnectionParams,
|
||||
#[structopt(flatten)]
|
||||
rialto_sign: RialtoSigningParams,
|
||||
#[structopt(flatten)]
|
||||
prometheus_params: PrometheusParams,
|
||||
},
|
||||
}
|
||||
|
||||
/// Prometheus metrics params.
|
||||
#[derive(StructOpt)]
|
||||
pub struct PrometheusParams {
|
||||
/// Do not expose a Prometheus metric endpoint.
|
||||
#[structopt(long)]
|
||||
pub no_prometheus: bool,
|
||||
/// Expose Prometheus endpoint at given interface.
|
||||
#[structopt(long, default_value = "127.0.0.1")]
|
||||
pub prometheus_host: String,
|
||||
/// Expose Prometheus endpoint at given port.
|
||||
#[structopt(long, default_value = "9616")]
|
||||
pub prometheus_port: u16,
|
||||
}
|
||||
|
||||
impl From<PrometheusParams> for Option<relay_utils::metrics::MetricsParams> {
|
||||
fn from(cli_params: PrometheusParams) -> Option<relay_utils::metrics::MetricsParams> {
|
||||
if !cli_params.no_prometheus {
|
||||
Some(relay_utils::metrics::MetricsParams {
|
||||
host: cli_params.prometheus_host,
|
||||
port: cli_params.prometheus_port,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! declare_chain_options {
|
||||
($chain:ident, $chain_prefix:ident) => {
|
||||
paste::item! {
|
||||
|
||||
@@ -45,6 +45,7 @@ async fn run_command(command: cli::Command) -> Result<(), String> {
|
||||
millau,
|
||||
rialto,
|
||||
rialto_sign,
|
||||
prometheus_params,
|
||||
} => {
|
||||
let millau_client = MillauClient::new(ConnectionParams {
|
||||
host: millau.millau_host,
|
||||
@@ -61,7 +62,7 @@ async fn run_command(command: cli::Command) -> Result<(), String> {
|
||||
rialto_sign.rialto_signer_password.as_deref(),
|
||||
)
|
||||
.map_err(|e| format!("Failed to parse rialto-signer: {:?}", e))?;
|
||||
millau_headers_to_rialto::run(millau_client, rialto_client, rialto_sign);
|
||||
millau_headers_to_rialto::run(millau_client, rialto_client, rialto_sign, prometheus_params.into());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,12 @@ impl TargetClient<MillauHeadersToRialto> for RialtoTargetClient {
|
||||
}
|
||||
|
||||
/// Run Millau-to-Rialto headers sync.
|
||||
pub fn run(millau_client: MillauClient, rialto_client: RialtoClient, rialto_sign: RialtoSigningParams) {
|
||||
pub fn run(
|
||||
millau_client: MillauClient,
|
||||
rialto_client: RialtoClient,
|
||||
rialto_sign: RialtoSigningParams,
|
||||
metrics_params: Option<relay_utils::metrics::MetricsParams>,
|
||||
) {
|
||||
let millau_tick = Duration::from_secs(5);
|
||||
let rialto_tick = Duration::from_secs(5);
|
||||
let sync_params = HeadersSyncParams {
|
||||
@@ -108,7 +113,6 @@ pub fn run(millau_client: MillauClient, rialto_client: RialtoClient, rialto_sign
|
||||
prune_depth: 256,
|
||||
target_tx_mode: TargetTransactionMode::Signed,
|
||||
};
|
||||
let metrics_params = None;
|
||||
|
||||
headers_relay::sync_loop::run(
|
||||
MillauSourceClient::new(millau_client),
|
||||
|
||||
Reference in New Issue
Block a user