v0.2.11-pre.004

This commit is contained in:
2026-08-25 21:47:47 +02:00
parent f4413ebbb0
commit 60afb51451
23 changed files with 1862 additions and 117 deletions

View File

@@ -1,13 +1,16 @@
// file: crates/ksp-offchain-transport-lib/src/http_settings.rs
// version: 2
// version: 3
//! Crate-wide bounded HTTP runtime settings shared by off-chain capability families.
const DEFAULT_CONNECT_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(5);
const DEFAULT_MAX_RESPONSE_BODY_BYTES: usize = 1_048_576;
const DEFAULT_REQUEST_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10);
#[cfg(test)]
const MAX_CONNECT_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
#[cfg(test)]
const MAX_REQUEST_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(120);
#[cfg(test)]
const MAX_RESPONSE_BODY_BYTES: usize = 4_194_304;
/// Crate-internal HTTP client settings with defensive hard bounds.
@@ -19,7 +22,8 @@ pub(crate) struct HttpClientSettings {
}
impl crate::HttpClientSettings {
/// Creates one validated HTTP settings value.
/// Creates one validated HTTP settings value for deterministic settings tests until runtime configuration consumes this constructor.
#[cfg(test)]
pub(crate) fn new(
connect_timeout: std::time::Duration,
request_timeout: std::time::Duration,
@@ -69,6 +73,7 @@ impl std::default::Default for crate::HttpClientSettings {
}
}
#[cfg(test)]
fn invalid_http_settings(message: &str, field: &'static str) -> ksp_core_lib::Result<crate::HttpClientSettings> {
ksp_logging_lib::warn!(target: crate::TRACING_TARGET, field = field, "rejected invalid off-chain HTTP client settings");
return std::result::Result::Err(ksp_core_lib::Error::new(crate::ERROR_CODE_HTTP_SETTINGS_INVALID, message).with_context("field", field));