mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-25 10:35:48 +00:00
rpc servers CLI: add --max--subscriptions--per--connection + fix a few bugs (#11461)
* cli: fix RPC CLI nits * remove needless lines * cargo fmt * Update client/service/src/lib.rs Co-authored-by: James Wilson <james@jsdw.me> Co-authored-by: James Wilson <james@jsdw.me>
This commit is contained in:
@@ -115,6 +115,11 @@ pub struct RunCmd {
|
|||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub rpc_max_response_size: Option<usize>,
|
pub rpc_max_response_size: Option<usize>,
|
||||||
|
|
||||||
|
/// Set the the maximum concurrent subscriptions per connection.
|
||||||
|
/// Default is 1024.
|
||||||
|
#[clap(long)]
|
||||||
|
pub rpc_max_subscriptions_per_connection: Option<usize>,
|
||||||
|
|
||||||
/// Expose Prometheus exporter on all interfaces.
|
/// Expose Prometheus exporter on all interfaces.
|
||||||
///
|
///
|
||||||
/// Default is local.
|
/// Default is local.
|
||||||
@@ -459,6 +464,18 @@ impl CliConfiguration for RunCmd {
|
|||||||
Ok(self.rpc_max_payload)
|
Ok(self.rpc_max_payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn rpc_max_request_size(&self) -> Result<Option<usize>> {
|
||||||
|
Ok(self.rpc_max_request_size)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn rpc_max_response_size(&self) -> Result<Option<usize>> {
|
||||||
|
Ok(self.rpc_max_response_size)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn rpc_max_subscriptions_per_connection(&self) -> Result<Option<usize>> {
|
||||||
|
Ok(self.rpc_max_subscriptions_per_connection)
|
||||||
|
}
|
||||||
|
|
||||||
fn ws_max_out_buffer_capacity(&self) -> Result<Option<usize>> {
|
fn ws_max_out_buffer_capacity(&self) -> Result<Option<usize>> {
|
||||||
Ok(self.ws_max_out_buffer_capacity)
|
Ok(self.ws_max_out_buffer_capacity)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -369,6 +369,11 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
|||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get maximum number of subscriptions per connection.
|
||||||
|
fn rpc_max_subscriptions_per_connection(&self) -> Result<Option<usize>> {
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
|
||||||
/// Get maximum WS output buffer capacity.
|
/// Get maximum WS output buffer capacity.
|
||||||
fn ws_max_out_buffer_capacity(&self) -> Result<Option<usize>> {
|
fn ws_max_out_buffer_capacity(&self) -> Result<Option<usize>> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
@@ -539,7 +544,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
|||||||
rpc_max_request_size: self.rpc_max_request_size()?,
|
rpc_max_request_size: self.rpc_max_request_size()?,
|
||||||
rpc_max_response_size: self.rpc_max_response_size()?,
|
rpc_max_response_size: self.rpc_max_response_size()?,
|
||||||
rpc_id_provider: None,
|
rpc_id_provider: None,
|
||||||
rpc_max_subs_per_conn: None,
|
rpc_max_subs_per_conn: self.rpc_max_subscriptions_per_connection()?,
|
||||||
ws_max_out_buffer_capacity: self.ws_max_out_buffer_capacity()?,
|
ws_max_out_buffer_capacity: self.ws_max_out_buffer_capacity()?,
|
||||||
prometheus_config: self
|
prometheus_config: self
|
||||||
.prometheus_config(DCV::prometheus_listen_port(), &chain_spec)?,
|
.prometheus_config(DCV::prometheus_listen_port(), &chain_spec)?,
|
||||||
|
|||||||
@@ -480,11 +480,18 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn legacy_cli_parsing(config: &Configuration) -> (Option<usize>, Option<usize>, Option<usize>) {
|
fn legacy_cli_parsing(config: &Configuration) -> (Option<usize>, Option<usize>, Option<usize>) {
|
||||||
let ws_max_response_size = config.ws_max_out_buffer_capacity.map(|max| {
|
let ws_max_response_size = match (
|
||||||
eprintln!("DEPRECATED: `--ws_max_out_buffer_capacity` has been removed use `rpc-max-response-size or rpc-max-request-size` instead");
|
config.ws_max_out_buffer_capacity,
|
||||||
eprintln!("Setting WS `rpc-max-response-size` to `max(ws_max_out_buffer_capacity, rpc_max_response_size)`");
|
config.rpc_max_response_size,
|
||||||
std::cmp::max(max, config.rpc_max_response_size.unwrap_or(0))
|
) {
|
||||||
});
|
(Some(legacy_max), max) => {
|
||||||
|
eprintln!("DEPRECATED: `--ws_max_out_buffer_capacity` has been removed; use `rpc-max-response-size or rpc-max-request-size` instead");
|
||||||
|
eprintln!("Setting WS `rpc-max-response-size` to `max(ws_max_out_buffer_capacity, rpc_max_response_size)`");
|
||||||
|
Some(std::cmp::max(legacy_max, max.unwrap_or(0)))
|
||||||
|
},
|
||||||
|
(None, Some(m)) => Some(m),
|
||||||
|
(None, None) => None,
|
||||||
|
};
|
||||||
|
|
||||||
let max_request_size = match (config.rpc_max_payload, config.rpc_max_request_size) {
|
let max_request_size = match (config.rpc_max_payload, config.rpc_max_request_size) {
|
||||||
(Some(legacy_max), max) => {
|
(Some(legacy_max), max) => {
|
||||||
@@ -498,7 +505,7 @@ fn legacy_cli_parsing(config: &Configuration) -> (Option<usize>, Option<usize>,
|
|||||||
(None, None) => None,
|
(None, None) => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let http_max_response_size = match (config.rpc_max_payload, config.rpc_max_request_size) {
|
let http_max_response_size = match (config.rpc_max_payload, config.rpc_max_response_size) {
|
||||||
(Some(legacy_max), max) => {
|
(Some(legacy_max), max) => {
|
||||||
eprintln!("DEPRECATED: `--rpc_max_payload` has been removed use `rpc-max-response-size or rpc-max-request-size` instead");
|
eprintln!("DEPRECATED: `--rpc_max_payload` has been removed use `rpc-max-response-size or rpc-max-request-size` instead");
|
||||||
eprintln!(
|
eprintln!(
|
||||||
|
|||||||
Reference in New Issue
Block a user