busbar-sf-client 0.0.1

Core HTTP client infrastructure for Salesforce APIs with retry, compression, and rate limiting
Documentation

sf-client

Core HTTP client infrastructure for Salesforce APIs.

This crate provides the foundational HTTP client with:

  • Automatic retry with exponential backoff and jitter
  • Compression support (gzip, deflate)
  • Rate limit detection and handling
  • ETag/conditional request support
  • Connection pooling
  • Request/response tracing

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    Application Layer                        │
│  (sf-rest, sf-bulk, sf-metadata, sf-tooling)               │
└─────────────────────────────────────────────────────────────┘
                             │
                             ▼
┌─────────────────────────────────────────────────────────────┐
│                   SalesforceClient                          │
│  - Holds credentials + HTTP client                          │
│  - Provides typed JSON methods (get_json, post_json, etc.)  │
│  - Handles authentication headers                           │
└─────────────────────────────────────────────────────────────┘
                             │
                             ▼
┌─────────────────────────────────────────────────────────────┐
│                    SfHttpClient                             │
│  - Raw HTTP with retry, compression, rate limiting          │
│  - Request building with conditionals                       │
│  - Response handling                                        │
└─────────────────────────────────────────────────────────────┘

Example

use sf_client::{SalesforceClient, ClientConfig};
use sf_auth::SalesforceCredentials;

#[tokio::main]
async fn main() -> Result<(), sf_client::Error> {
    let creds = SalesforceCredentials::from_env()?;
    let client = SalesforceClient::new(creds)?;

    // Typed JSON request
    let user: serde_json::Value = client
        .get_json("/services/oauth2/userinfo")
        .await?;

    // POST with body
    let result: CreateResult = client
        .post_json("/services/data/v62.0/sobjects/Account", &new_account)
        .await?;

    Ok(())
}