Configuration & Settings Management
Relevant source files
The following files were used as context for generating this wiki page:
Configuration and Settings Management in flext-oracle-wms provides an enterprise-grade, type-safe framework for managing connectivity to Oracle Warehouse Management System (WMS) Cloud. The system is built on Pydantic v2 to ensure strict data validation and supports multiple configuration patterns, including environment variables, .env files, and programmatic injection via the FLEXT container.
Sources: src/README.md, src/flext_oracle_wms/README.md, src/flext_oracle_wms/settings.py
Core Architecture
The configuration architecture is centered around the FlextOracleWmsSettings class, which serves as a Single Source of Truth (SSOT). This class handles default values, validation logic, and integration with the wider FLEXT ecosystem's dependency injection container.
Component Interaction Flow
The following diagram illustrates how settings are initialized and validated before being consumed by the Oracle WMS Client.
The diagram shows the flow from raw configuration sources to the finalized client initialization.
Sources: examples/01_basic_usage.py:46-63, examples/02_configuration.py:76-107
Settings Definition
Configuration parameters are strictly typed. The system distinguishes between connectivity details (Base URL, credentials) and operational parameters (timeouts, retry logic).
Configuration Options
| Parameter | Type | Default | Description |
|---|---|---|---|
base_url | str | "http://localhost:8080" | The endpoint for the Oracle WMS Cloud instance. |
username | str | "" | Authentication username (Basic/Bearer/API Key). |
password | str | "" | Authentication password or secret. |
timeout | float | 30.0 | Maximum seconds for API requests. |
retry_attempts | int | 3 | Number of attempts for failed requests. |
api_version | str | "LGF_V10" | Target Oracle WMS LGF API version. |
verify_ssl | bool | True | Whether to verify SSL certificates. |
Sources: src/flext_oracle_wms/settings.py, tests/unit/test_config.py:38-44, examples/03_complete_functionality_showcase.py:61-72
Management Patterns
1. Singleton Pattern & Dependency Injection
The library implements a singleton behavior for settings to ensure consistency across the application. Developers can use FlextOracleWmsSettings.fetch_global() to retrieve the active configuration.
from flext_oracle_wms import FlextOracleWmsSettings
from flext_core import FlextContainer
# Bind settings to the shared container
settings = FlextOracleWmsSettings(base_url="https://wms.oraclecloud.com")
container = FlextContainer.shared()
container.bind("FlextOracleWmsSettings", settings.model_dump())
Sources: examples/01_basic_usage.py:46-63, tests/unit/test_config_module.py:22-26
2. Environment-Driven Configuration
The system automatically maps environment variables prefixed with FLEXT_ORACLE_WMS_ to the settings object. For enterprise deployments, environment-specific configurations (Dev, Staging, Prod) are often managed via custom models that wrap the base settings.
Validation & Quality Gates
Validation occurs at two levels: Pydantic type validation and business rule validation via the validate_config() method. This ensures that parameters like timeouts and retry counts are within operational thresholds.
Business Rules Validation
- Base URL: Must be present and should ideally use HTTPS.
- Credentials: Username and password fields must not be empty for production use.
- Timeouts: Must be positive; values below 10 seconds trigger warnings.
- Retries: Cannot be negative.
Sources: examples/02_configuration.py:141-168, tests/unit/test_config.py:28-32
Testing Factories
To facilitate unit testing without requiring live environment variables, the library provides a testing factory:
FlextOracleWmsSettings.testing_config(): Returns a pre-configured instance pointing tohttps://test-wms.example.com.FlextOracleWmsSettings.reset_for_testing(): Clears the singleton instance to allow fresh configuration in test suites.
Sources: tests/unit/test_config_module.py:43-47, tests/unit/test_config_module.py:49-54
Summary
Configuration and Settings Management in this project ensures that all Oracle WMS interactions are governed by validated, type-safe parameters. By combining Pydantic validation with FLEXT's dependency injection container, the system provides a robust foundation for both simple scripts and complex data pipelines, supporting various authentication methods and environment-specific overrides while maintaining strict architectural compliance.