From ab783beb609521a5a9cd2a06970d1c47c0783ec2 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Tue, 21 May 2024 10:26:52 +0100 Subject: [PATCH] fix: Revert API poll settings names (#111) --- src/edge_proxy/environments.py | 2 +- src/edge_proxy/server.py | 6 +++--- src/edge_proxy/settings.py | 10 ++-------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/edge_proxy/environments.py b/src/edge_proxy/environments.py index 5c0088e..d1e835b 100644 --- a/src/edge_proxy/environments.py +++ b/src/edge_proxy/environments.py @@ -37,7 +37,7 @@ def __init__( self.cache = cache or LocalMemEnvironmentsCache() self.settings = settings or AppSettings() self._client = client or httpx.AsyncClient( - timeout=settings.api_poll_timeout_seconds, + timeout=settings.api_poll_timeout, ) self.last_updated_at = None diff --git a/src/edge_proxy/server.py b/src/edge_proxy/server.py index 3c26d4a..ff355ef 100644 --- a/src/edge_proxy/server.py +++ b/src/edge_proxy/server.py @@ -21,7 +21,7 @@ setup_logging(settings.logging) environment_service = EnvironmentService( LocalMemEnvironmentsCache(), - httpx.AsyncClient(timeout=settings.api_poll_timeout_seconds), + httpx.AsyncClient(timeout=settings.api_poll_timeout), settings, ) app = FastAPI() @@ -44,7 +44,7 @@ async def health_check(): with suppress(TypeError): last_updated = datetime.now() - environment_service.last_updated_at buffer = 30 * len(settings.environment_key_pairs) # 30s per environment - if last_updated.total_seconds() <= settings.api_poll_frequency_seconds + buffer: + if last_updated.total_seconds() <= settings.api_poll_frequency + buffer: return ORJSONResponse(status_code=200, content={"status": "ok"}) return ORJSONResponse(status_code=500, content={"status": "error"}) @@ -77,7 +77,7 @@ async def identity( @app.on_event("startup") @repeat_every( - seconds=settings.api_poll_frequency_seconds, + seconds=settings.api_poll_frequency, raise_exceptions=True, logger=structlog.get_logger(__name__), ) diff --git a/src/edge_proxy/settings.py b/src/edge_proxy/settings.py index 6a10484..0a987c6 100644 --- a/src/edge_proxy/settings.py +++ b/src/edge_proxy/settings.py @@ -99,14 +99,8 @@ class AppSettings(BaseModel): ) ] api_url: HttpUrl = "https://edge.api.flagsmith.com/api/v1" - api_poll_frequency_seconds: int = Field( - default=10, - aliases=["api_poll_frequency_seconds", "api_poll_frequency"], - ) - api_poll_timeout_seconds: int = Field( - default=5, - aliases=["api_poll_timeout_seconds", "api_poll_timeout"], - ) + api_poll_frequency: int = Field(default=10) + api_poll_timeout: int = Field(default=5) endpoint_caches: EndpointCachesSettings | None = None allow_origins: List[str] = ["*"] logging: LoggingSettings = LoggingSettings()