nv_ingest_client.message_clients.rest package#
Submodules#
nv_ingest_client.message_clients.rest.rest_client module#
- class nv_ingest_client.message_clients.rest.rest_client.RestClient(
- host: str,
- port: int,
- max_retries: int = 0,
- max_backoff: int = 32,
- connection_timeout: int = 300,
- http_allocator: ~typing.Any = <class 'httpx.AsyncClient'>,
Bases:
MessageBrokerClientBase
A client for interfacing with the nv-ingest HTTP endpoint, providing mechanisms for sending and receiving messages with retry logic and connection management.
- Parameters:
host (str) – The hostname of the HTTP server.
port (int) – The port number of the HTTP server.
max_retries (int, optional) – The maximum number of retry attempts for operations. Default is 0 (no retries).
max_backoff (int, optional) – The maximum backoff delay between retries in seconds. Default is 32 seconds.
connection_timeout (int, optional) – The timeout in seconds for connecting to the HTTP server. Default is 300 seconds.
http_allocator (Any, optional) – The HTTP client allocator.
- client#
The HTTP client instance used for operations.
- Type:
Any
- fetch_message(
- job_id: str,
- timeout: float = 10,
Fetches a message from the specified queue with retries on failure.
- Parameters:
job_id (str) – The server-side job identifier.
timeout (float) – The timeout in seconds for blocking until a message is available.
- Returns:
The fetched message wrapped in a ResponseSchema object.
- Return type:
- generate_url(user_provided_url, user_provided_port) str [source]#
Examines the user defined URL for http*://. If that pattern is detected the URL is used as provided by the user. If that pattern does not exist then the assumption is made that the endpoint is simply http:// and that is prepended to the user supplied endpoint.
- Parameters:
str (user_provided_url) – Endpoint where the Rest service is running
- Returns:
Fully validated URL
- Return type:
str
- get_client() Any [source]#
Returns a HTTP client instance, reconnecting if necessary.
- Returns:
The HTTP client instance.
- Return type:
Any
- property max_retries: int#
- perform_retry_backoff(existing_retries) int [source]#
Attempts to perform a backoff retry delay. This function accepts the current number of retries that have been attempted and compares that with the maximum number of retries allowed. If the current number of retries exceeds the max then a RuntimeError is raised.
- Parameters:
existing_retries (int) – The number of retries that have been attempted for this operation thus far
- Returns:
The updated number of retry attempts that have been made for this operation
- Return type:
int
- Raises:
RuntimeError – Raised if the maximum number of retry attempts has been reached.
- ping() ResponseSchema [source]#
Checks if the HTTP server is responsive.
- Returns:
True if the server responds to a ping, False otherwise.
- Return type:
bool
- submit_message(
- channel_name: str,
- message: str,
- for_nv_ingest: bool = False,
Submits a JobSpec to a specified HTTP endpoint with retries on failure.
- Parameters:
channel_name (str) – Not used as part of RestClient but defined in MessageClientBase
message (str) – The message to submit.
for_nv_ingest (bool) – Not used as part of RestClient but defined in Message
- Returns:
The response from the server wrapped in a ResponseSchema object.
- Return type: