Skip to main content

Crate reqx

Crate reqx 

Source
Expand description

reqx is an internal HTTP transport crate for API SDKs with HTTP/1.1 + HTTP/2 support.

§Quick Start

use std::time::Duration;
use reqx::prelude::{Client, RetryPolicy};
use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct CreateItemResponse {
    id: String,
}

    let client = Client::builder("https://api.example.com")
        .client_name("my-sdk")
        .request_timeout(Duration::from_secs(3))
        .total_timeout(Duration::from_secs(8))
        .retry_policy(
            RetryPolicy::standard()
                .max_attempts(3)
                .base_backoff(Duration::from_millis(100))
                .max_backoff(Duration::from_millis(800)),
        )
        .build()?;

    let created: CreateItemResponse = client
        .post("/v1/items")
        .idempotency_key("create-item-001")?
        .json(&serde_json::json!({ "name": "demo" }))?
        .send_json()
        .await?;

    println!("created id={}", created.id);
    Ok(())
  • Use RetryPolicy::standard() for SDK traffic.
  • Set both request timeout and total timeout.
  • For POST retries, always set idempotency_key(...).
  • Reach for advanced when you need non-default transport controls.

Modules§

advanced
Advanced transport controls and extensibility points.
blocking_blocking
prelude
Recommended imports for most SDK transport code.

Structs§

Client_async
ClientBuilder_async
RequestBuilder_async
Builds and executes a single request against an existing Client.
Response
ResponseStream_async

Enums§

Error
ErrorCode
TimeoutPhase
TransportErrorKind

Type Aliases§

Result