Skip to content

Commit

Permalink
feat: remove unnecessary setting `health_check.count_stale_documents_…
Browse files Browse the repository at this point in the history
…as_failing` (#123)

* Remove unnecessary additional setting and rely on grace_period=None

* Formatting changes
  • Loading branch information
matthewelwell authored Sep 4, 2024
1 parent 9d7c10d commit 6cde1e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/edge_proxy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ async def health_check():
last_successful_update=None,
)

if settings.health_check.count_stale_documents_as_failing:
buffer = settings.health_check.grace_period_seconds * len(
settings.environment_key_pairs
)
grace_period = settings.health_check.environment_update_grace_period_seconds
if grace_period is not None:
buffer = grace_period * len(settings.environment_key_pairs)
threshold = datetime.now() - timedelta(
seconds=settings.api_poll_frequency_seconds + buffer
)
Expand Down
5 changes: 2 additions & 3 deletions src/edge_proxy/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
from enum import Enum
from pathlib import Path
from typing import Any
from typing import Any, Optional

import structlog

Expand Down Expand Up @@ -101,8 +101,7 @@ class ServerSettings(BaseModel):


class HealthCheckSettings(BaseModel):
count_stale_documents_as_failing: bool = True
grace_period_seconds: int = 30
environment_update_grace_period_seconds: Optional[int] = 30


class AppSettings(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_health_check_returns_200_if_cache_is_stale_and_health_check_configured_
) -> None:
# Given
settings = AppSettings(
health_check=HealthCheckSettings(count_stale_documents_as_failing=False)
health_check=HealthCheckSettings(environment_update_grace_period_seconds=None)
)
mocker.patch("edge_proxy.server.settings", settings)

Expand Down

0 comments on commit 6cde1e8

Please sign in to comment.