Skip to content

Commit

Permalink
fix: Revert API poll settings names (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 authored May 21, 2024
1 parent 013ef4f commit ab783be
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/edge_proxy/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/edge_proxy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"})
Expand Down Expand Up @@ -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__),
)
Expand Down
10 changes: 2 additions & 8 deletions src/edge_proxy/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ab783be

Please sign in to comment.