Problem Statement
Currently, user-provided HTTP client instances are not bound by any contract or enforced structure. This allows clients without essential properties such as timeout or session, which leads to inconsistent behavior during SDK network operations and configuration overrides.
Proposed Solution
Introduce a new abstract base component named HttpClientProvider to define the expected interface for all custom HTTP client implementations.
This class enforces two required properties:
timeout: The request timeout in seconds.
session: A configured requests.Session instance for making HTTP calls.
This ensures all injected clients adhere to a consistent structure and are compatible with the SDK’s internal HTTP handling.
Why
The addition of this component provides:
- A formal contract for custom HTTP clients.
- Consistency and reliability in how timeout and session are accessed.
- Improved extensibility for developers integrating their own HTTP clients.
- Clear typing and readability, enhancing maintainability across the SDK codebase.
Example Implementation
from requests import Session
from sdk_core.http_client_provider import HttpClientProvider
class CustomClient(HttpClientProvider):
def __init__(self):
self._session = Session()
self._timeout = 30.0
@property
def timeout(self) -> float:
return self._timeout
@property
def session(self) -> Session:
return self._session
Impact
- Enables a standardized extension point for custom HTTP client integrations.
- Prevents runtime issues caused by incomplete or misconfigured clients.
- Improves type safety and maintainability of the SDK’s HTTP layer.
Problem Statement
Currently, user-provided HTTP client instances are not bound by any contract or enforced structure. This allows clients without essential properties such as
timeoutorsession, which leads to inconsistent behavior during SDK network operations and configuration overrides.Proposed Solution
Introduce a new abstract base component named
HttpClientProviderto define the expected interface for all custom HTTP client implementations.This class enforces two required properties:
timeout: The request timeout in seconds.session: A configuredrequests.Sessioninstance for making HTTP calls.This ensures all injected clients adhere to a consistent structure and are compatible with the SDK’s internal HTTP handling.
Why
The addition of this component provides:
Example Implementation
Impact