pub struct AppConfig {
pub server: ServerConfig,
pub cache: CacheConfig,
pub auth: AuthConfig,
pub oauth: OAuthConfig,
pub logging: LoggingConfig,
pub performance: PerformanceConfig,
}Expand description
Application configuration
Contains server, cache, authentication, logging, and performance configuration.
§Fields
server: Server configurationcache: Cache configurationauth: Authentication configuration (OAuth and API Key)logging: Logging configurationperformance: Performance configuration
§Hot Reload Support
The following configuration items support hot reload (runtime update without restart):
loggingsection: All fieldsauthsection: All fields (including API Key and OAuth)cachesection: TTL-related fields (default_ttl,crate_docs_ttl_secs,item_docs_ttl_secs,search_results_ttl_secs)performancesection:rate_limit_per_second,concurrent_request_limit,enable_metrics,enable_response_compression
The following configuration items do not support hot reload (require server restart):
serversection: All fields (host, port,transport_mode,max_connections, etc.)cachesection:cache_type,memory_size,redis_url(cache initialization parameters)performancesection:http_client_*,cache_max_size,cache_default_ttl_secs,metrics_port
Fields§
§server: ServerConfigServer configuration
cache: CacheConfigCache configuration
auth: AuthConfigAuthentication configuration (OAuth and API Key)
oauth: OAuthConfigOAuth configuration (backwards compatible, prefer using auth.oauth)
logging: LoggingConfigLogging configuration
performance: PerformanceConfigPerformance configuration
Implementations§
Source§impl AppConfig
impl AppConfig
Sourcepub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Error>
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Error>
Load configuration from file
§Errors
Returns an error if file does not exist, cannot be read, or format is invalid
Sourcepub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>
pub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>
Save configuration to file
§Errors
Returns an error if configuration cannot be serialized, directory cannot be created, or file cannot be written
Sourcepub fn validate(&self) -> Result<(), Error>
pub fn validate(&self) -> Result<(), Error>
Validate configuration
§Errors
Returns an error if configuration is invalid (e.g., empty hostname, invalid port, etc.)
Sourcepub fn from_env() -> Result<EnvAppConfig, Error>
pub fn from_env() -> Result<EnvAppConfig, Error>
Load configuration from environment variables
Returns an EnvAppConfig where all fields are Option<T>, allowing
the caller to distinguish between “not set” and “explicitly set”.
§Errors
Returns an error if environment variable format is invalid (e.g., non-numeric port)
Sourcepub fn merge(
file_config: Option<Self>,
env_config: Option<EnvAppConfig>,
) -> Self
pub fn merge( file_config: Option<Self>, env_config: Option<EnvAppConfig>, ) -> Self
Merge configuration (environment variables take precedence over file configuration)
Uses Option<T> semantics from EnvAppConfig to determine which values
were explicitly set via environment variables. This eliminates fragile
hardcoded default comparisons.