diff --git a/configs/local.yaml b/configs/local.yaml index 172fac5..435f612 100644 --- a/configs/local.yaml +++ b/configs/local.yaml @@ -6,13 +6,11 @@ app: port: 8000 host: 0.0.0.0 reload: True - thread_limiter_total_tokens: 40 http: port: 8080 host: 0.0.0.0 reload: True - thread_limiter_total_tokens: 40 rpc: port: 50051 @@ -22,7 +20,6 @@ logging: level_app: debug level_libs: info handlers: [console] - syslog_app: null syslog_facility: null syslog_mapping: null @@ -31,8 +28,6 @@ logging: postgres: host: postgres port: 5432 - user: postgres - password: postgres database: featureflags timeout: 10 diff --git a/configs/test.yaml b/configs/test.yaml index 998cab3..18c0862 100644 --- a/configs/test.yaml +++ b/configs/test.yaml @@ -6,13 +6,11 @@ app: port: 8000 host: 0.0.0.0 reload: True - thread_limiter_total_tokens: 40 http: port: 8080 host: 0.0.0.0 reload: True - thread_limiter_total_tokens: 40 rpc: port: 50051 @@ -22,7 +20,6 @@ logging: level_app: debug level_libs: info handlers: [console] - syslog_app: null syslog_facility: null syslog_mapping: null @@ -31,8 +28,6 @@ logging: postgres: host: postgres-test port: 5432 - user: postgres - password: postgres database: featureflags-test timeout: 10 diff --git a/docker-compose.yaml b/docker-compose.yaml index f1b91c5..b2053ad 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -47,6 +47,8 @@ services: PYTHONIOENCODING: UTF-8 PYTHONUNBUFFERED: 1 CONFIG_PATH: configs/local.yaml + PGUSER: postgres + PGPASS: postgres networks: - main volumes: diff --git a/featureflags/config.py b/featureflags/config.py index 6a76bab..00cdd75 100644 --- a/featureflags/config.py +++ b/featureflags/config.py @@ -3,6 +3,7 @@ from pathlib import Path import yaml +from pydantic import Field from pydantic_settings import BaseSettings log = logging.getLogger(__name__) @@ -17,7 +18,6 @@ class LoggingSettings(BaseSettings): level_app: str level_libs: str handlers: list[str] - syslog_app: str | None syslog_facility: str | None syslog_mapping: dict | None @@ -27,8 +27,8 @@ class LoggingSettings(BaseSettings): class PostgresSettings(BaseSettings): host: str port: int - user: str - password: str + user: str = Field(..., alias="PGUSER") + password: str = Field(..., alias="PGPASS") database: str timeout: int = 10 @@ -56,14 +56,14 @@ class AppSettings(BaseSettings): port: int = 8000 host: str = "0.0.0.0" reload: bool = False - thread_limiter_total_tokens: int = 40 + max_concurrent_threads: int = 40 class HttpSettings(BaseSettings): port: int = 8080 host: str = "0.0.0.0" reload: bool = False - thread_limiter_total_tokens: int = 40 + max_concurrent_threads: int = 40 class RpcSettings(BaseSettings): diff --git a/featureflags/http/lifecycle.py b/featureflags/http/lifecycle.py index 15cc983..2c7dd0e 100644 --- a/featureflags/http/lifecycle.py +++ b/featureflags/http/lifecycle.py @@ -13,8 +13,9 @@ async def startup() -> None: """Application startup functions.""" # https://github.com/tiangolo/fastapi/discussions/8587 + # Adjust this value to limit the number of concurrent threads. limiter = anyio.to_thread.current_default_thread_limiter() - limiter.total_tokens = config.http.thread_limiter_total_tokens + limiter.total_tokens = config.http.max_concurrent_threads await container.init_resources() diff --git a/featureflags/logging.py b/featureflags/logging.py index 703ebe1..013d938 100644 --- a/featureflags/logging.py +++ b/featureflags/logging.py @@ -35,21 +35,6 @@ def configure_logging(package: str) -> None: logging.root.setLevel(config.logging.level_libs.upper()) logging.getLogger(package).setLevel(config.logging.level_app.upper()) - if "logevo" in config.logging.handlers: - if len(config.logging.handlers) > 1: - raise ValueError("logevo handler must be used alone") - - try: - import logevo - - logevo.configure_logging() - except ImportError as e: - raise ImportError( - "logevo handler is used but 'logevo' package is not installed" - ) from e - else: - log.info("Logevo configured") - if "console" in config.logging.handlers: logging.root.addHandler(create_console_handler()) diff --git a/featureflags/web/lifecycle.py b/featureflags/web/lifecycle.py index bd3daae..f552563 100644 --- a/featureflags/web/lifecycle.py +++ b/featureflags/web/lifecycle.py @@ -13,8 +13,9 @@ async def startup() -> None: """Application startup functions.""" # https://github.com/tiangolo/fastapi/discussions/8587 + # Adjust this value to limit the number of concurrent threads. limiter = anyio.to_thread.current_default_thread_limiter() - limiter.total_tokens = config.app.thread_limiter_total_tokens + limiter.total_tokens = config.app.max_concurrent_threads await container.init_resources() diff --git a/pdm.lock b/pdm.lock index d39177b..1b4e930 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev", "docs", "lint", "test"] strategy = ["cross_platform", "inherit_metadata"] lock_version = "4.4.1" -content_hash = "sha256:9a1107332d22df98c9218951c14639bd8bb105feb9f863b950dffa542b7bdd82" +content_hash = "sha256:400f203a046e8f97666641339bfa745307ed4777610d79f5fff9dc8591fc63e7" [[package]] name = "aiopg"