From c811bb24755ae52cb80e39c459882dec0156240e Mon Sep 17 00:00:00 2001 From: Christos Hadjiaslanis Date: Mon, 11 Nov 2024 15:40:18 +0000 Subject: [PATCH] Replaced redundant calls to format. --- linera-rpc/src/grpc/server.rs | 2 +- linera-storage-service/src/client.rs | 12 ++++++------ linera-storage-service/src/common.rs | 8 +++++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/linera-rpc/src/grpc/server.rs b/linera-rpc/src/grpc/server.rs index 142df169bbc..0b27bd08331 100644 --- a/linera-rpc/src/grpc/server.rs +++ b/linera-rpc/src/grpc/server.rs @@ -352,7 +352,7 @@ where receiver .for_each_concurrent(max_concurrent_tasks, |(cross_chain_request, shard_id)| { let shard = network.shard(shard_id); - let remote_address = format!("http://{}", shard.address()); + let remote_address = shard.http_address(); let pool = pool.clone(); let nickname = nickname.clone(); diff --git a/linera-storage-service/src/client.rs b/linera-storage-service/src/client.rs index 8f268d3e184..de18af08d96 100644 --- a/linera-storage-service/src/client.rs +++ b/linera-storage-service/src/client.rs @@ -383,7 +383,7 @@ impl AdminKeyValueStore for ServiceStoreClientInternal { namespace: &str, root_key: &[u8], ) -> Result { - let endpoint = format!("http://{}", config.endpoint); + let endpoint = config.http_address(); let endpoint = Endpoint::from_shared(endpoint)?; let channel = endpoint.connect_lazy(); let semaphore = config @@ -426,7 +426,7 @@ impl AdminKeyValueStore for ServiceStoreClientInternal { async fn list_all(config: &Self::Config) -> Result, ServiceStoreError> { let query = RequestListAll {}; let request = tonic::Request::new(query); - let endpoint = format!("http://{}", config.endpoint); + let endpoint = config.http_address(); let endpoint = Endpoint::from_shared(endpoint)?; let mut client = StoreProcessorClient::connect(endpoint).await?; let response = client.process_list_all(request).await?; @@ -442,7 +442,7 @@ impl AdminKeyValueStore for ServiceStoreClientInternal { async fn delete_all(config: &Self::Config) -> Result<(), ServiceStoreError> { let query = RequestDeleteAll {}; let request = tonic::Request::new(query); - let endpoint = format!("http://{}", config.endpoint); + let endpoint = config.http_address(); let endpoint = Endpoint::from_shared(endpoint)?; let mut client = StoreProcessorClient::connect(endpoint).await?; let _response = client.process_delete_all(request).await?; @@ -453,7 +453,7 @@ impl AdminKeyValueStore for ServiceStoreClientInternal { let namespace = bcs::to_bytes(namespace)?; let query = RequestExistsNamespace { namespace }; let request = tonic::Request::new(query); - let endpoint = format!("http://{}", config.endpoint); + let endpoint = config.http_address(); let endpoint = Endpoint::from_shared(endpoint)?; let mut client = StoreProcessorClient::connect(endpoint).await?; let response = client.process_exists_namespace(request).await?; @@ -466,7 +466,7 @@ impl AdminKeyValueStore for ServiceStoreClientInternal { let namespace = bcs::to_bytes(namespace)?; let query = RequestCreateNamespace { namespace }; let request = tonic::Request::new(query); - let endpoint = format!("http://{}", config.endpoint); + let endpoint = config.http_address(); let endpoint = Endpoint::from_shared(endpoint)?; let mut client = StoreProcessorClient::connect(endpoint).await?; let _response = client.process_create_namespace(request).await?; @@ -477,7 +477,7 @@ impl AdminKeyValueStore for ServiceStoreClientInternal { let namespace = bcs::to_bytes(namespace)?; let query = RequestDeleteNamespace { namespace }; let request = tonic::Request::new(query); - let endpoint = format!("http://{}", config.endpoint); + let endpoint = config.http_address(); let endpoint = Endpoint::from_shared(endpoint)?; let mut client = StoreProcessorClient::connect(endpoint).await?; let _response = client.process_delete_namespace(request).await?; diff --git a/linera-storage-service/src/common.rs b/linera-storage-service/src/common.rs index eaca57cb831..9d3d7ad2eb6 100644 --- a/linera-storage-service/src/common.rs +++ b/linera-storage-service/src/common.rs @@ -102,11 +102,17 @@ pub(crate) static LRU_STORAGE_SERVICE_METRICS: LazyLock = #[derive(Debug, Clone)] pub struct ServiceStoreConfig { /// The endpoint used by the shared store - pub endpoint: String, + endpoint: String, /// The common configuration of the key value store pub common_config: CommonStoreConfig, } +impl ServiceStoreConfig { + pub fn http_address(&self) -> String { + format!("http://{}", self.endpoint) + } +} + /// Obtains the binary of the executable. /// The path depends whether the test are run in the directory "linera-storage-service" /// or in the main directory