Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove unnecessary setting health_check.count_stale_documents_as_failing #123

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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