Skip to content

Commit

Permalink
refactor: create new configuration v1 mod with figment
Browse files Browse the repository at this point in the history
- Clone config strcuctures into a new mod `v1`.
- Introduce versioning for configuration API.
- Split config sections into submodules.

TODO:

- Still using root mod types in production.
- Not using figment to build config in production.
  • Loading branch information
josecelano committed May 8, 2024
1 parent 636e779 commit e7d344c
Show file tree
Hide file tree
Showing 5 changed files with 513 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/configuration/src/v1/health_check_api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

/// Configuration for the Health Check API.
#[serde_as]
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
pub struct HealthCheckApi {
/// The address the API will bind to.
/// The format is `ip:port`, for example `127.0.0.1:1313`. If you want to
/// listen to all interfaces, use `0.0.0.0`. If you want the operating
/// system to choose a random port, use port `0`.
pub bind_address: String,
}
23 changes: 23 additions & 0 deletions packages/configuration/src/v1/http_tracker.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, NoneAsEmptyString};

/// Configuration for each HTTP tracker.
#[serde_as]
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
pub struct HttpTracker {
/// Weather the HTTP tracker is enabled or not.
pub enabled: bool,
/// The address the tracker will bind to.
/// The format is `ip:port`, for example `0.0.0.0:6969`. If you want to
/// listen to all interfaces, use `0.0.0.0`. If you want the operating
/// system to choose a random port, use port `0`.
pub bind_address: String,
/// Weather the HTTP tracker will use SSL or not.
pub ssl_enabled: bool,
/// Path to the SSL certificate file. Only used if `ssl_enabled` is `true`.
#[serde_as(as = "NoneAsEmptyString")]
pub ssl_cert_path: Option<String>,
/// Path to the SSL key file. Only used if `ssl_enabled` is `true`.
#[serde_as(as = "NoneAsEmptyString")]
pub ssl_key_path: Option<String>,
}
Loading

0 comments on commit e7d344c

Please sign in to comment.