Module client_config

Module client_config 

Source
Expand description

Configuration management for the Apollo client.

This module provides the ClientConfig struct and related functionality for configuring the Apollo client. It supports both direct configuration and environment variable-based configuration, with platform-specific optimizations for native Rust and WebAssembly targets.

§Configuration Sources

  • Direct Configuration: Manually specify all configuration fields
  • Environment Variables: Automatically load configuration from environment variables
  • Mixed Approach: Load from environment variables and override specific fields

§Environment Variables

The following environment variables are supported:

  • APP_ID: Your application identifier in Apollo
  • APOLLO_CONFIG_SERVICE: The Apollo configuration server URL
  • IDC: The cluster name (defaults to “default”)
  • APOLLO_ACCESS_KEY_SECRET: Authentication secret key
  • APOLLO_LABEL: Labels for grayscale release targeting
  • APOLLO_CACHE_DIR: Local cache directory
  • APOLLO_CACHE_TTL: Cache time-to-live in seconds
  • APOLLO_ALLOW_INSECURE_HTTPS: Whether to allow insecure HTTPS connections

§Platform Support

  • Native Rust: Full feature set including file caching and environment variable support
  • WebAssembly: Optimized for browser environments with memory-only caching

§Examples

§Direct Configuration

use apollo_rust_client::client_config::ClientConfig;

let config = ClientConfig {
    app_id: "my-app".to_string(),
    config_server: "http://apollo-server:8080".to_string(),
    cluster: "default".to_string(),
    secret: Some("secret-key".to_string()),
    cache_dir: None, // Uses default
    label: Some("production".to_string()),
    ip: Some("192.168.1.100".to_string()),
    allow_insecure_https: None,
    #[cfg(not(target_arch = "wasm32"))]
    cache_ttl: None,
};

§Environment Variable Configuration

use apollo_rust_client::client_config::ClientConfig;

// Requires APP_ID and APOLLO_CONFIG_SERVICE environment variables
let config = ClientConfig::from_env()?;

Structs§

ClientConfig
Configuration settings for the Apollo client.

Enums§

Error
Comprehensive error types that can occur during client configuration.