pub struct Config {
pub environment: String,
pub azure: AzureConfig,
pub application: ApplicationConfig,
}
Expand description
Main application configuration structure.
Contains all configuration sections including Azure service settings and application-specific parameters.
Fields§
§environment: String
Environment name (e.g., “development”, “production”)
azure: AzureConfig
Azure service configuration
application: ApplicationConfig
Application-specific configuration
Implementations§
Source§impl Config
impl Config
Sourcefn default_allowed_domains() -> Vec<String>
fn default_allowed_domains() -> Vec<String>
Default list of allowed domains for crawling.
Returns a curated list of documentation and reference sites that are commonly used for development and programming.
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Creates a new configuration instance from environment variables.
Loads all required and optional configuration values from environment variables. Required variables will cause an error if not present, while optional variables have sensible defaults.
§Environment Variables
§Required
AZURE_SEARCH_SERVICE_NAME
: Azure Cognitive Search service nameAZURE_SEARCH_API_KEY
: Azure Cognitive Search API keyAZURE_COSMOS_ENDPOINT
: CosmosDB account endpoint URLAZURE_COSMOS_KEY
: CosmosDB primary access key
§Optional (with defaults)
ENVIRONMENT
: Environment name (default: “development”)AZURE_SEARCH_API_VERSION
: Search API version (default: “2023-11-01”)AZURE_SEARCH_INDEX_NAME
: Search index name (default: “web-pages”)AZURE_COSMOS_DATABASE_NAME
: Database name (default: “search-engine”)AZURE_COSMOS_CONTAINER_NAME
: Container name (default: “web-pages”)MAX_CRAWL_DEPTH
: Maximum crawl depth (default: 5)CRAWL_DELAY_MS
: Delay between requests (default: 1000)MAX_CONCURRENT_REQUESTS
: Concurrent requests (default: 10)USER_AGENT
: HTTP User-Agent (default: “SearchBot/1.0”)ALLOWED_DOMAINS
: Comma-separated domains (default: curated list)PERIODIC_INDEX_INTERVAL_DAYS
: Re-indexing interval (default: 7)DUPLICATE_REMOVAL_INTERVAL_HOURS
: Duplicate removal interval (default: 24)ADMIN_API_KEY
: API key for admin endpoints (default: “admin-key-change-me”)
§Returns
A configured Config
instance ready for use.
§Errors
Returns an error if any required environment variable is missing or invalid.
Sourcepub fn is_production(&self) -> bool
pub fn is_production(&self) -> bool
Checks if the application is running in production environment.
§Returns
true
if the environment is set to “production”, false
otherwise.
Sourcepub fn is_development(&self) -> bool
pub fn is_development(&self) -> bool
Checks if the application is running in development environment.
§Returns
true
if the environment is set to “development”, false
otherwise.
Sourcepub fn search_service_url(&self) -> String
pub fn search_service_url(&self) -> String
Constructs the base URL for the Azure Cognitive Search service.
§Returns
The complete HTTPS URL for the search service.
Sourcepub fn search_index_url(&self) -> String
pub fn search_index_url(&self) -> String
Sourcepub fn search_documents_url(&self) -> String
pub fn search_documents_url(&self) -> String
Constructs the URL for search index documents operations.
§Returns
The complete URL for document operations (add, update, delete).
Sourcepub fn search_query_url(&self) -> String
pub fn search_query_url(&self) -> String
Constructs the URL for search query operations.
§Returns
The complete URL for performing search queries.