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(...).

Modules§

blocking_blocking
prelude

Structs§

AdaptiveConcurrencyPolicy
AdvancedConfig
AsyncResumableUploader_async
BlockingResumableUploader
CircuitBreakerPolicy
Client_async
ClientBuilder_async
MetricsSnapshot
PermissiveRetryEligibility
PolicyBackoffSource
PrimaryEndpointSelector
RateLimitPolicy
RedirectPolicy
RequestContext
Response
ResponseStream_async
ResumableUploadCheckpoint
ResumableUploadOptions
ResumableUploadResult
RetryBudgetPolicy
RetryDecision
RetryPolicy
RoundRobinEndpointSelector
StandardBodyCodec
StrictRetryEligibility
SystemClock
UploadedPart

Enums§

ClientProfile
Error
ErrorCode
PartChecksumAlgorithm
ResumableUploadError
ServerThrottleScope
StatusPolicy
TimeoutPhase
TlsBackend
TlsRootStore
TransportErrorKind

Constants§

RESUMABLE_UPLOAD_CHECKPOINT_VERSION

Traits§

AsyncResumableUploadBackend_async
BackoffSource
BlockingResumableUploadBackend
BodyCodec
Clock
EndpointSelector
Interceptor
Observer
RetryClassifier
RetryEligibility

Type Aliases§

Result