v0.2.5-pre.010.fix.001
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-onchain-transport-lib/src/client.rs
|
||||
// version: 6
|
||||
// version: 7
|
||||
|
||||
/// Passive runtime availability reported for one logical HTTP endpoint or role.
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||
@@ -177,8 +177,9 @@ impl HttpEndpointClient {
|
||||
return Self::new_with_notify(settings, std::sync::Arc::new(tokio::sync::Notify::new()));
|
||||
}
|
||||
|
||||
/// Creates a new with notify value for `HttpEndpointClient`.
|
||||
pub(crate) fn new_with_notify(settings: crate::HttpEndpointSettings, notify: std::sync::Arc<tokio::sync::Notify>) -> ksp_core_lib::Result<Self> {
|
||||
let validation = crate::settings::validate_endpoint_settings(&settings);
|
||||
let validation = crate::validate_endpoint_settings(&settings);
|
||||
if let std::result::Result::Err(error) = validation {
|
||||
return std::result::Result::Err(error);
|
||||
}
|
||||
@@ -239,6 +240,7 @@ impl HttpEndpointClient {
|
||||
return self.inner.settings.request_timeout();
|
||||
}
|
||||
|
||||
/// Executes the crate-internal post json rpc operation for `HttpEndpointClient`.
|
||||
pub(crate) async fn post_json_rpc(&self, payload: &str, timeout: std::time::Duration) -> ksp_core_lib::Result<HttpEndpointHttpResponse> {
|
||||
if timeout.is_zero() {
|
||||
return std::result::Result::Err(
|
||||
@@ -301,6 +303,7 @@ impl HttpEndpointClient {
|
||||
};
|
||||
}
|
||||
|
||||
/// Executes the crate-internal matching role operation for `HttpEndpointClient`.
|
||||
pub(crate) fn matching_role<'a>(
|
||||
&'a self,
|
||||
role: &crate::HttpRoleName,
|
||||
@@ -322,6 +325,7 @@ impl HttpEndpointClient {
|
||||
return std::option::Option::None;
|
||||
}
|
||||
|
||||
/// Executes the crate-internal matching role runtime operation for `HttpEndpointClient`.
|
||||
pub(crate) fn matching_role_runtime(
|
||||
&self,
|
||||
role: &crate::HttpRoleName,
|
||||
@@ -352,6 +356,7 @@ impl HttpEndpointClient {
|
||||
return std::option::Option::None;
|
||||
}
|
||||
|
||||
/// Returns the current availability.
|
||||
pub(crate) fn availability(&self) -> crate::HttpEndpointAvailability {
|
||||
if !self.enabled() {
|
||||
return crate::HttpEndpointAvailability::Disabled;
|
||||
@@ -393,6 +398,7 @@ impl std::fmt::Debug for HttpEndpointClient {
|
||||
}
|
||||
}
|
||||
|
||||
/// Crate-internal `HttpEndpointHttpResponse` state shared across the owning crate.
|
||||
pub(crate) struct HttpEndpointHttpResponse {
|
||||
status: u16,
|
||||
retry_after: std::option::Option<std::time::Duration>,
|
||||
@@ -400,14 +406,17 @@ pub(crate) struct HttpEndpointHttpResponse {
|
||||
}
|
||||
|
||||
impl HttpEndpointHttpResponse {
|
||||
/// Returns the current status.
|
||||
pub(crate) const fn status(&self) -> u16 {
|
||||
return self.status;
|
||||
}
|
||||
|
||||
/// Returns the current retry after.
|
||||
pub(crate) const fn retry_after(&self) -> std::option::Option<std::time::Duration> {
|
||||
return self.retry_after;
|
||||
}
|
||||
|
||||
/// Returns the current body.
|
||||
pub(crate) fn body(&self) -> &[u8] {
|
||||
return self.body.as_slice();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user