feat: add corex-storage crate for unified storage abstraction
- Introduced corex-storage crate with support for local disk, S3-compatible, and Google Cloud Storage backends. - Implemented StorageDriver trait for various storage backends. - Added LocalFileStorage for local disk operations. - Added S3Storage for S3-compatible object storage with multipart upload support. - Added GcsStorage for Google Cloud Storage operations. - Included error handling for storage operations. - Added tests for each storage backend to ensure functionality. - Created README.md for documentation and usage examples. - Added Apache and MIT licenses for open-source compliance.
This commit is contained in:
1 parent
6a4b2b8f54
commit
db4f277336
47 files changed
No files matched your search
@@ -0,0 +1,49 @@
|
||||
# corex-config
|
||||
|
||||
Type-safe, dynamic configuration: load `.env`, YAML, JSON, or TOML directly
|
||||
into a typed Rust struct, merge multiple sources with environment variables
|
||||
taking priority, and optionally hot-reload when the source files change.
|
||||
|
||||
## Features
|
||||
|
||||
- `env` (default) — `.env` file loading via `dotenvy`.
|
||||
- `yaml` / `toml` (default) — structured file parsing (`.json` is always available).
|
||||
- `hot-reload` (default) — watch files and swap in a freshly reloaded value.
|
||||
|
||||
## Usage
|
||||
|
||||
```rust
|
||||
use serde::Deserialize;
|
||||
use corex_config::ConfigLoader;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
struct AppConfig {
|
||||
port: u16,
|
||||
database_url: String,
|
||||
}
|
||||
|
||||
let config: AppConfig = ConfigLoader::new()
|
||||
.merge_file("config.yaml".as_ref())?
|
||||
.merge_env("APP") // APP_PORT, APP_DATABASE_URL override the file
|
||||
.build()?;
|
||||
```
|
||||
|
||||
### Hot-reload
|
||||
|
||||
```rust
|
||||
use corex_config::DynamicConfig;
|
||||
# use serde::Deserialize;
|
||||
# #[derive(Debug, Deserialize, Clone)] struct AppConfig { port: u16 }
|
||||
|
||||
let cfg = DynamicConfig::<AppConfig>::watch_files(
|
||||
vec!["config.yaml".into()],
|
||||
|| corex_config::ConfigLoader::new().merge_file("config.yaml".as_ref())?.build(),
|
||||
)?;
|
||||
|
||||
let mut changes = cfg.subscribe();
|
||||
tokio::spawn(async move {
|
||||
while changes.recv().await.is_ok() {
|
||||
println!("config reloaded: {:?}", cfg.get());
|
||||
}
|
||||
});
|
||||
```
|
||||
Reference in new issue
Block a user