|
|
@@ -88,12 +88,12 @@ class Settings(BaseSettings):
|
|
|
|
|
|
@property
|
|
|
def REDIS_CELERY_SENTINEL_URL(self) -> str:
|
|
|
- # Celery/Kombu 兼容的 Sentinel URL:
|
|
|
- # sentinel://:password@host:port/db;sentinel://:password@host:port/db
|
|
|
- # 哨兵节点本身需要认证时,密码放在 URL 的 auth 段
|
|
|
- # sentinel_pwd = self.REDIS_SENTINEL_PASSWORD or self.REDIS_PASSWORD
|
|
|
- sentinel_pwd = self.REDIS_SENTINEL_PASSWORD
|
|
|
- auth = f":{quote(sentinel_pwd, safe='')}@" if sentinel_pwd else ""
|
|
|
+ # Celery/Kombu Sentinel URL 格式:
|
|
|
+ # sentinel://:redis_password@sentinel_host:port/db;...
|
|
|
+ # URL 中的 auth 密码 = Redis 主从节点密码
|
|
|
+ # (Kombu 通过 Sentinel 发现主节点地址后,用此密码向 Redis 主节点认证)
|
|
|
+ # Sentinel 自身的密码(如有)通过 broker_transport_options["sentinel_kwargs"]["password"] 传递
|
|
|
+ auth = f":{quote(self.REDIS_PASSWORD, safe='')}@" if self.REDIS_PASSWORD else ""
|
|
|
return ";".join(
|
|
|
f"sentinel://{auth}{host}:{port}/{self.REDIS_DB}"
|
|
|
for host, port in self.REDIS_SENTINEL_NODES
|