Telemetry

This commit is contained in:
Alphonse Paix
2025-08-22 08:14:59 +02:00
parent 709bd28a8c
commit f1290d0bc5
11 changed files with 239 additions and 46 deletions

View File

@@ -1,3 +1,4 @@
use secrecy::{ExposeSecret, SecretString};
use serde::Deserialize;
pub fn get_configuration() -> Result<Settings, config::ConfigError> {
@@ -19,24 +20,33 @@ pub struct Settings {
#[derive(Deserialize)]
pub struct DatabaseSettings {
pub username: String,
pub password: String,
pub password: SecretString,
pub port: u16,
pub host: String,
pub database_name: String,
}
impl DatabaseSettings {
pub fn connection_string(&self) -> String {
pub fn connection_string(&self) -> SecretString {
format!(
"postgres://{}:{}@{}:{}/{}",
self.username, self.password, self.host, self.port, self.database_name
self.username,
self.password.expose_secret(),
self.host,
self.port,
self.database_name
)
.into()
}
pub fn connection_string_without_db(&self) -> String {
pub fn connection_string_without_db(&self) -> SecretString {
format!(
"postgres://{}:{}@{}:{}",
self.username, self.password, self.host, self.port
self.username,
self.password.expose_secret(),
self.host,
self.port
)
.into()
}
}