Skip to main content

dynamodb_client

Function dynamodb_client 

Source
pub async fn dynamodb_client() -> &'static Client
Expand description

Get a reference to the global DynamoDB client

Automatically initializes the client with sensible defaults if not already initialized. For custom configuration, call init or init_with_client before using this function.

§Auto-Initialization

If not explicitly initialized, this function will automatically configure:

  • Adaptive retry mode with 3 max attempts
  • Exponential backoff starting at 1 second
  • Connect timeout: 3 seconds
  • Read timeout: 20 seconds
  • Operation timeout: 60 seconds
  • LocalStack support via AWS_PROFILE=localstack

§Example

// Client auto-initializes with defaults on first use
let client = dynamo_table::dynamodb_client().await;
// Use client for custom operations

§Custom Configuration Example

// Initialize with custom config before first use
let config = dynamo_table::defaults(dynamo_table::BehaviorVersion::latest())
    .region(dynamo_table::Region::new("us-west-2"))
    .load()
    .await;
dynamo_table::init(&config).await;

// Now uses custom configuration
let client = dynamo_table::dynamodb_client().await;