mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
Co-authored-by: harsh_sharma_juspay <harsh.sharma@juspay.in> Co-authored-by: Ivor Dsouza <ivor.dsouza@juspay.in> Co-authored-by: Chethan Rao <70657455+Chethan-rao@users.noreply.github.com> Co-authored-by: nain-F49FF806 <126972030+nain-F49FF806@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: akshay.s <akshay.s@juspay.in> Co-authored-by: Gnanasundari24 <118818938+Gnanasundari24@users.noreply.github.com>
50 lines
1.2 KiB
Rust
50 lines
1.2 KiB
Rust
use masking::Secret;
|
|
|
|
#[derive(Debug, Clone, serde::Deserialize)]
|
|
pub struct Database {
|
|
pub username: String,
|
|
pub password: Secret<String>,
|
|
pub host: String,
|
|
pub port: u16,
|
|
pub dbname: String,
|
|
pub pool_size: u32,
|
|
pub connection_timeout: u64,
|
|
pub queue_strategy: QueueStrategy,
|
|
pub min_idle: Option<u32>,
|
|
pub max_lifetime: Option<u64>,
|
|
}
|
|
|
|
#[derive(Debug, serde::Deserialize, Clone, Copy, Default)]
|
|
#[serde(rename_all = "PascalCase")]
|
|
pub enum QueueStrategy {
|
|
#[default]
|
|
Fifo,
|
|
Lifo,
|
|
}
|
|
|
|
impl From<QueueStrategy> for bb8::QueueStrategy {
|
|
fn from(value: QueueStrategy) -> Self {
|
|
match value {
|
|
QueueStrategy::Fifo => Self::Fifo,
|
|
QueueStrategy::Lifo => Self::Lifo,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for Database {
|
|
fn default() -> Self {
|
|
Self {
|
|
username: String::new(),
|
|
password: Secret::<String>::default(),
|
|
host: "localhost".into(),
|
|
port: 5432,
|
|
dbname: String::new(),
|
|
pool_size: 5,
|
|
connection_timeout: 10,
|
|
queue_strategy: QueueStrategy::default(),
|
|
min_idle: None,
|
|
max_lifetime: None,
|
|
}
|
|
}
|
|
}
|