mirror of
https://github.com/langgenius/dify.git
synced 2026-04-15 18:06:36 +08:00
refactor(api): type _get_cluster_connection_health_params with TypedDict (#34999)
This commit is contained in:
parent
6bacf7f953
commit
44ebfa3bb8
@ -141,6 +141,12 @@ class RedisHealthParamsDict(TypedDict):
|
||||
health_check_interval: int | None
|
||||
|
||||
|
||||
class RedisClusterHealthParamsDict(TypedDict):
|
||||
retry: Retry
|
||||
socket_timeout: float | None
|
||||
socket_connect_timeout: float | None
|
||||
|
||||
|
||||
class RedisBaseParamsDict(TypedDict):
|
||||
username: str | None
|
||||
password: str | None
|
||||
@ -211,7 +217,7 @@ def _get_connection_health_params() -> RedisHealthParamsDict:
|
||||
)
|
||||
|
||||
|
||||
def _get_cluster_connection_health_params() -> dict[str, Any]:
|
||||
def _get_cluster_connection_health_params() -> RedisClusterHealthParamsDict:
|
||||
"""Get retry and timeout parameters for Redis Cluster clients.
|
||||
|
||||
RedisCluster does not support ``health_check_interval`` as a constructor
|
||||
@ -219,8 +225,13 @@ def _get_cluster_connection_health_params() -> dict[str, Any]:
|
||||
here. Only ``retry``, ``socket_timeout``, and ``socket_connect_timeout``
|
||||
are passed through.
|
||||
"""
|
||||
params: dict[str, Any] = dict(_get_connection_health_params())
|
||||
return {k: v for k, v in params.items() if k != "health_check_interval"}
|
||||
health_params = _get_connection_health_params()
|
||||
result: RedisClusterHealthParamsDict = {
|
||||
"retry": health_params["retry"],
|
||||
"socket_timeout": health_params["socket_timeout"],
|
||||
"socket_connect_timeout": health_params["socket_connect_timeout"],
|
||||
}
|
||||
return result
|
||||
|
||||
|
||||
def _get_base_redis_params() -> RedisBaseParamsDict:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user