refactor: add infrastructure dependency injection to pypi_proxy
Add dependency injection helper functions for HttpClientManager and CacheService, along with imports for the new infrastructure modules (http_client, cache_service, db_utils).
This commit is contained in:
@@ -26,12 +26,25 @@ from .database import get_db
|
||||
from .models import UpstreamSource, CachedUrl, Artifact, Project, Package, PackageVersion, ArtifactDependency
|
||||
from .storage import S3Storage, get_storage
|
||||
from .config import get_env_upstream_sources, get_settings
|
||||
from .http_client import HttpClientManager
|
||||
from .cache_service import CacheService, CacheCategory
|
||||
from .db_utils import ArtifactRepository
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/pypi", tags=["pypi-proxy"])
|
||||
|
||||
|
||||
def get_http_client(request: Request) -> HttpClientManager:
|
||||
"""Get HttpClientManager from app state."""
|
||||
return request.app.state.http_client
|
||||
|
||||
|
||||
def get_cache(request: Request) -> CacheService:
|
||||
"""Get CacheService from app state."""
|
||||
return request.app.state.cache
|
||||
|
||||
|
||||
# Timeout configuration for proxy requests
|
||||
PROXY_CONNECT_TIMEOUT = 30.0
|
||||
PROXY_READ_TIMEOUT = 60.0
|
||||
|
||||
Reference in New Issue
Block a user