diff --git a/crates/ecstore/src/lock_utils.rs b/crates/ecstore/src/lock_utils.rs index 02281d05d..98b9f320c 100644 --- a/crates/ecstore/src/lock_utils.rs +++ b/crates/ecstore/src/lock_utils.rs @@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::HashMap; -use std::sync::Arc; -use rustfs_lock::client::{LockClient, local::LocalClient, remote::RemoteClient}; use crate::disk::endpoint::Endpoint; use crate::error::Result; +use rustfs_lock::client::{LockClient, local::LocalClient, remote::RemoteClient}; +use std::collections::HashMap; +use std::sync::Arc; /// Create unique lock clients from endpoints /// This function creates one client per unique host:port combination /// to avoid duplicate connections to the same server pub async fn create_unique_clients(endpoints: &[Endpoint]) -> Result>> { let mut unique_endpoints: HashMap = HashMap::new(); - + // Collect unique endpoints based on host:port for endpoint in endpoints { if endpoint.is_local { @@ -32,16 +32,16 @@ pub async fn create_unique_clients(endpoints: &[Endpoint]) -> Result Result); } } - + Ok(clients) } @@ -124,13 +124,13 @@ mod tests { let clients = create_unique_clients(&endpoints).await.unwrap(); // Should create 3 clients: 1 local + 2 unique remote assert_eq!(clients.len(), 3); - + // Check that we have one local client let local_count = clients.iter().filter(|c| futures::executor::block_on(c.is_local())).count(); assert_eq!(local_count, 1); - + // Check that we have two remote clients let remote_count = clients.iter().filter(|c| !futures::executor::block_on(c.is_local())).count(); assert_eq!(remote_count, 2); } -} \ No newline at end of file +}