|
|
@@ -89,9 +89,12 @@ class Settings(BaseSettings):
|
|
|
@property
|
|
|
def REDIS_CELERY_SENTINEL_URL(self) -> str:
|
|
|
# Celery/Kombu 兼容的 Sentinel URL:
|
|
|
- # sentinel://host:port/db;sentinel://host:port/db
|
|
|
+ # sentinel://:password@host:port/db;sentinel://:password@host:port/db
|
|
|
+ # 哨兵节点本身需要认证时,密码放在 URL 的 auth 段
|
|
|
+ sentinel_pwd = self.REDIS_SENTINEL_PASSWORD or self.REDIS_PASSWORD
|
|
|
+ auth = f":{quote(sentinel_pwd, safe='')}@" if sentinel_pwd else ""
|
|
|
return ";".join(
|
|
|
- f"sentinel://{host}:{port}/{self.REDIS_DB}"
|
|
|
+ f"sentinel://{auth}{host}:{port}/{self.REDIS_DB}"
|
|
|
for host, port in self.REDIS_SENTINEL_NODES
|
|
|
)
|
|
|
|