Skip to content

Conversation

@plutopulp
Copy link
Owner

@plutopulp plutopulp commented Dec 15, 2025

Summary

Introduces an HTTP client abstraction layer to decouple the download infrastructure from aiohttp specifics, improving testability and enabling future client implementations.

Key changes:

  • New infrastructure/http module with BaseHttpClient ABC, AiohttpClient implementation, and factory functions for SSL context/connector creation
  • New exception hierarchy: RheoError → InfrastructureError → HttpClientError → ClientNotInitialisedError
  • Updated DownloadWorker, WorkerPool, and DownloadManager to depend on BaseHttpClient instead of aiohttp.ClientSession
  • Removed inline SSL context creation from DownloadManager.open(), now handled by AiohttpClient
  • Updated test fixtures to use BaseHttpClient abstraction consistently

Benefits:

  • Cleaner separation of concerns, HTTP client lifecycle is self-contained
  • Foundation for supporting alternative HTTP clients in future

Introduces infrastructure/http module with:
- BaseHttpClient ABC defining the client contract (open/close/closed/get)
- Factory functions for SSL context and secure connector creation
- AiohttpClient implementation with flexible configuration options
- Support for both context manager and manual lifecycle management

Refactors exception hierarchy:
- Add RheoError as top-level base for all library exceptions
- Add InfrastructureError -> HttpClientError -> ClientNotInitialisedError
- DownloadManagerError now inherits from RheoError
Replaces inline SSL context and connector creation with AiohttpClient.
Manager now accepts BaseHttpClient, enabling future client swapping.
Only calls open() on clients it owns, preserving injected client behaviour.
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@plutopulp plutopulp changed the title Http client abstraction HTTP client abstraction layer with BaseHttpClient ABC Dec 15, 2025
@plutopulp plutopulp marked this pull request as ready for review December 15, 2025 12:16
@plutopulp plutopulp merged commit a32442d into main Dec 15, 2025
5 checks passed
@plutopulp plutopulp deleted the http-client-abstraction branch December 15, 2025 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants