mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-07 07:55:16 +02:00
chore: fix the case when circuit breaker config is not set
This commit is contained in:
parent
dfb741e475
commit
c58735f5d3
2 changed files with 12 additions and 10 deletions
|
|
@ -137,10 +137,10 @@ class CircuitBreakerConfigRequest(BaseModel):
|
|||
|
||||
|
||||
class CircuitBreakerConfigResponse(BaseModel):
|
||||
enabled: bool
|
||||
failure_threshold: float
|
||||
window_seconds: int
|
||||
min_calls_in_window: int
|
||||
enabled: bool = False
|
||||
failure_threshold: float = 0.5
|
||||
window_seconds: int = 120
|
||||
min_calls_in_window: int = 5
|
||||
|
||||
|
||||
class CreateCampaignRequest(BaseModel):
|
||||
|
|
@ -232,7 +232,7 @@ def _build_campaign_response(campaign, workflow_name: str) -> CampaignResponse:
|
|||
# Get max_concurrency, schedule_config, circuit_breaker from orchestrator_metadata
|
||||
max_concurrency = None
|
||||
schedule_config = None
|
||||
circuit_breaker_config = None
|
||||
circuit_breaker_config = CircuitBreakerConfigResponse()
|
||||
if campaign.orchestrator_metadata:
|
||||
max_concurrency = campaign.orchestrator_metadata.get("max_concurrency")
|
||||
sc = campaign.orchestrator_metadata.get("schedule_config")
|
||||
|
|
|
|||
|
|
@ -270,10 +270,10 @@ class ScheduleConfigResponse(BaseModel):
|
|||
|
||||
|
||||
class CircuitBreakerConfigResponse(BaseModel):
|
||||
enabled: bool
|
||||
failure_threshold: float
|
||||
window_seconds: int
|
||||
min_calls_in_window: int
|
||||
enabled: bool = False
|
||||
failure_threshold: float = 0.5
|
||||
window_seconds: int = 120
|
||||
min_calls_in_window: int = 5
|
||||
|
||||
|
||||
class LastCampaignSettingsResponse(BaseModel):
|
||||
|
|
@ -339,7 +339,7 @@ async def get_campaign_defaults(user: UserModel = Depends(get_user)):
|
|||
|
||||
max_conc = None
|
||||
sched = None
|
||||
cb = None
|
||||
cb = CircuitBreakerConfigResponse()
|
||||
if last_campaign.orchestrator_metadata:
|
||||
max_conc = last_campaign.orchestrator_metadata.get("max_concurrency")
|
||||
sc = last_campaign.orchestrator_metadata.get("schedule_config")
|
||||
|
|
@ -354,6 +354,8 @@ async def get_campaign_defaults(user: UserModel = Depends(get_user)):
|
|||
cb_data = last_campaign.orchestrator_metadata.get("circuit_breaker")
|
||||
if cb_data:
|
||||
cb = CircuitBreakerConfigResponse(**cb_data)
|
||||
else:
|
||||
cb = CircuitBreakerConfigResponse()
|
||||
|
||||
last_campaign_settings = LastCampaignSettingsResponse(
|
||||
retry_config=retry,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue