v0.2.1-pre.003-fix.001
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-onchain-transport-lib/src/pool.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
/// Safe snapshot of the logical HTTP endpoint pool.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
@@ -23,7 +23,7 @@ impl HttpTransportPoolSnapshot {
|
||||
/// Returns the number of endpoints currently eligible for routing.
|
||||
#[must_use]
|
||||
pub fn available_endpoint_count(&self) -> usize {
|
||||
return self.endpoints.iter().filter(|endpoint| endpoint.availability() == crate::HttpEndpointAvailability::Available).count();
|
||||
return self.endpoints.iter().filter(|endpoint| return endpoint.availability() == crate::HttpEndpointAvailability::Available).count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,13 +132,13 @@ impl HttpTransportPool {
|
||||
if candidates.is_empty() {
|
||||
return selection_failed(role, request_kind);
|
||||
}
|
||||
candidates.sort_by_key(|candidate| candidate.priority);
|
||||
candidates.sort_by_key(|candidate| return candidate.priority);
|
||||
let first_candidate = candidates.first();
|
||||
let best_priority = match first_candidate {
|
||||
std::option::Option::Some(candidate) => candidate.priority,
|
||||
std::option::Option::None => return selection_failed(role, request_kind),
|
||||
};
|
||||
let best_tier: std::vec::Vec<PoolCandidate> = candidates.into_iter().take_while(|candidate| candidate.priority == best_priority).collect();
|
||||
let best_tier: std::vec::Vec<PoolCandidate> = candidates.into_iter().take_while(|candidate| return candidate.priority == best_priority).collect();
|
||||
let selected_position = self.next_position(role, request_kind, best_priority, best_tier.len());
|
||||
let selected = match best_tier.get(selected_position) {
|
||||
std::option::Option::Some(selected) => selected,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-onchain-transport-lib/unit_tests/pool.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
fn role(name: &str, priority: u32, request_kinds: std::vec::Vec<crate::HttpRequestKind>) -> crate::HttpEndpointRoleSettings {
|
||||
return crate::HttpEndpointRoleSettings::new(
|
||||
@@ -135,6 +135,13 @@ fn disabled_role_is_excluded_before_priority_selection() {
|
||||
1,
|
||||
crate::HttpRoleLimits::new(std::option::Option::None, std::option::Option::None, std::option::Option::None, std::option::Option::None),
|
||||
);
|
||||
let enabled_non_matching_role = crate::HttpEndpointRoleSettings::new(
|
||||
crate::HttpRoleName::new("maintenance"),
|
||||
true,
|
||||
std::vec![crate::HttpRequestKind::wildcard()],
|
||||
1,
|
||||
crate::HttpRoleLimits::new(std::option::Option::None, std::option::Option::None, std::option::Option::None, std::option::Option::None),
|
||||
);
|
||||
let disabled_role_endpoint = crate::HttpEndpointSettings::new(
|
||||
base.name(),
|
||||
true,
|
||||
@@ -144,7 +151,7 @@ fn disabled_role_is_excluded_before_priority_selection() {
|
||||
base.connect_timeout(),
|
||||
base.request_timeout(),
|
||||
base.max_idle_connections_per_host(),
|
||||
std::vec![disabled_role],
|
||||
std::vec![disabled_role, enabled_non_matching_role],
|
||||
);
|
||||
let pool = super::HttpTransportPool::new(settings(std::vec![
|
||||
disabled_role_endpoint,
|
||||
|
||||
Reference in New Issue
Block a user