refactor(runtime): wrap internode connection cache (#4036)

This commit is contained in:
Zhengchao An
2026-06-29 10:43:13 +08:00
committed by GitHub
parent df82e3e645
commit 9165de3241
5 changed files with 32 additions and 12 deletions
+10
View File
@@ -143,6 +143,16 @@ pub async fn evict_connection_with_log_level(addr: &str, log_level: ConnectionEv
}
}
/// Get a cached gRPC connection for the given address.
pub async fn cached_connection(addr: &str) -> Option<Channel> {
GLOBAL_CONN_MAP.read().await.get(addr).cloned()
}
/// Cache a gRPC connection for the given address.
pub async fn cache_connection(addr: String, channel: Channel) {
GLOBAL_CONN_MAP.write().await.insert(addr, channel);
}
/// Check if a connection exists in the cache for the given address.
///
/// # Arguments