v0.2.1-pre.005
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-onchain-transport-lib/src/pool.rs
|
||||
// version: 3
|
||||
// version: 4
|
||||
|
||||
/// Safe snapshot of the logical HTTP endpoint pool.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
@@ -169,6 +169,7 @@ struct HttpTransportPoolInner {
|
||||
clients: std::vec::Vec<crate::HttpEndpointClient>,
|
||||
retry: crate::HttpRetrySettings,
|
||||
notify: std::sync::Arc<tokio::sync::Notify>,
|
||||
request_ids: std::sync::atomic::AtomicU64,
|
||||
cursors: std::sync::Mutex<std::collections::BTreeMap<(std::string::String, std::string::String, u32), usize>>,
|
||||
}
|
||||
|
||||
@@ -194,6 +195,7 @@ impl HttpTransportPool {
|
||||
clients,
|
||||
retry: settings.retry().clone(),
|
||||
notify,
|
||||
request_ids: std::sync::atomic::AtomicU64::new(1),
|
||||
cursors: std::sync::Mutex::new(std::collections::BTreeMap::new()),
|
||||
}),
|
||||
};
|
||||
@@ -213,6 +215,14 @@ impl HttpTransportPool {
|
||||
return &self.inner.retry;
|
||||
}
|
||||
|
||||
pub(crate) fn next_request_id(&self) -> u64 {
|
||||
let id = self.inner.request_ids.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
if id == 0 {
|
||||
return self.inner.request_ids.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/// Selects an endpoint for one standard audited RPC method without reserving runtime capacity.
|
||||
///
|
||||
/// Request execution should use `acquire_for_method` so rate, cooldown and concurrency limits are enforced.
|
||||
@@ -424,7 +434,11 @@ impl HttpTransportPool {
|
||||
return std::time::Instant::now() < deadline;
|
||||
}
|
||||
|
||||
fn common_request_timeout(&self, role: &crate::HttpRoleName, request_kind: &crate::HttpRequestKind) -> ksp_core_lib::Result<std::time::Duration> {
|
||||
pub(crate) fn common_request_timeout(
|
||||
&self,
|
||||
role: &crate::HttpRoleName,
|
||||
request_kind: &crate::HttpRequestKind,
|
||||
) -> ksp_core_lib::Result<std::time::Duration> {
|
||||
let mut timeout: std::option::Option<std::time::Duration> = std::option::Option::None;
|
||||
for client in &self.inner.clients {
|
||||
if client.matching_role(role, request_kind).is_none() {
|
||||
|
||||
Reference in New Issue
Block a user