core.requester
Requester object to make HTTP requests to the Jobmon FastAPI services.
Attributes
Classes
Handles HTTP requests to the jobmon server with configurable OTLP integration. |
Functions
|
Return True if HTTP return codes that are deemed ok. |
|
Parse the response. |
Module Contents
- core.requester.logger
- core.requester.http_request_ok(status_code: int) bool
Return True if HTTP return codes that are deemed ok.
- class core.requester.Requester(service_url: str, retries_timeout: int = 300, retries_attempts: int = 10, request_timeout: int = 20, use_otlp: bool = False)
Handles HTTP requests to the jobmon server with configurable OTLP integration.
Initialize requester with optional OTLP support.
- Parameters:
service_url – The jobmon server URL
retries_timeout – Total timeout for retries in seconds
retries_attempts – Number of retry attempts
request_timeout – Individual request timeout in seconds
use_otlp – Whether to enable OTLP instrumentation
- service_url
- retries_timeout = 300
- retries_attempts = 10
- request_timeout = 20
- add_server_structlog_context(**kwargs: Any) None
Add the structlogging context if it has been provided.
- send_request(app_route: str, message: dict, request_type: str, tenacious: bool = True) Tuple[int, Any]
Send a request to the Jobmon server.
- async send_request_async(session: aiohttp.ClientSession, app_route: str, message: dict, request_type: str, tenacious: bool = True) Tuple[int, Any]
Send an async request to the Jobmon server with sophisticated retry logic.
This method provides the same robust retry capabilities as the sync version, using tenacity for exponential backoff with jitter, timeout protection, and comprehensive exception handling.
- Parameters:
session – An active aiohttp ClientSession for making requests.
app_route – The API route to request (will be appended to base URL).
message – Dictionary containing the request payload.
request_type – HTTP method - ‘get’, ‘post’, or ‘put’.
tenacious – Whether to enable retry logic (default: True).
- Returns:
Tuple of (status_code, response_content).
- Raises:
InvalidRequest – For 4xx client errors (no retry).
InvalidResponse – For 5xx server errors after exhausting retries.
RuntimeError – If retry budget is exceeded.