fix celery backend when use rabbitmq (#23238)
Signed-off-by: kenwoodjw <blackxin55+@gmail.com>
This commit is contained in:
parent
98aea05ad2
commit
1821726d4f
1 changed files with 7 additions and 2 deletions
|
|
@ -215,7 +215,7 @@ class DatabaseConfig(BaseSettings):
|
||||||
|
|
||||||
class CeleryConfig(DatabaseConfig):
|
class CeleryConfig(DatabaseConfig):
|
||||||
CELERY_BACKEND: str = Field(
|
CELERY_BACKEND: str = Field(
|
||||||
description="Backend for Celery task results. Options: 'database', 'redis'.",
|
description="Backend for Celery task results. Options: 'database', 'redis', 'rabbitmq'.",
|
||||||
default="redis",
|
default="redis",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -245,7 +245,12 @@ class CeleryConfig(DatabaseConfig):
|
||||||
|
|
||||||
@computed_field
|
@computed_field
|
||||||
def CELERY_RESULT_BACKEND(self) -> str | None:
|
def CELERY_RESULT_BACKEND(self) -> str | None:
|
||||||
return f"db+{self.SQLALCHEMY_DATABASE_URI}" if self.CELERY_BACKEND == "database" else self.CELERY_BROKER_URL
|
if self.CELERY_BACKEND in ("database", "rabbitmq"):
|
||||||
|
return f"db+{self.SQLALCHEMY_DATABASE_URI}"
|
||||||
|
elif self.CELERY_BACKEND == "redis":
|
||||||
|
return self.CELERY_BROKER_URL
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def BROKER_USE_SSL(self) -> bool:
|
def BROKER_USE_SSL(self) -> bool:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue