fix: apply Baidu Vector DB connection timeout when initializing Mochow client (#34328)

This commit is contained in:
jimmyzhuu
2026-04-01 14:16:09 +08:00
committed by GitHub
parent c51cd42cb4
commit b23ea0397a
2 changed files with 16 additions and 3 deletions

View File

@@ -195,7 +195,11 @@ class BaiduVector(BaseVector):
raise
def _init_client(self, config) -> MochowClient:
config = Configuration(credentials=BceCredentials(config.account, config.api_key), endpoint=config.endpoint)
config = Configuration(
credentials=BceCredentials(config.account, config.api_key),
endpoint=config.endpoint,
connection_timeout_in_mills=config.connection_timeout_in_mills,
)
client = MochowClient(config)
return client

View File

@@ -381,13 +381,22 @@ def test_init_client_constructs_configuration_and_client(baidu_module, monkeypat
monkeypatch.setattr(baidu_module, "MochowClient", client_cls)
vector = baidu_module.BaiduVector.__new__(baidu_module.BaiduVector)
config = SimpleNamespace(account="account", api_key="key", endpoint="https://endpoint")
config = SimpleNamespace(
account="account",
api_key="key",
endpoint="https://endpoint",
connection_timeout_in_mills=12_345,
)
client = vector._init_client(config)
assert client == "client"
credentials.assert_called_once_with("account", "key")
configuration.assert_called_once_with(credentials="credentials", endpoint="https://endpoint")
configuration.assert_called_once_with(
credentials="credentials",
endpoint="https://endpoint",
connection_timeout_in_mills=12_345,
)
client_cls.assert_called_once_with("configuration")