-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename fields in schema, generate schema on init, and add $schema field
- Loading branch information
Gil Mizrahi
committed
Mar 12, 2024
1 parent
ebfd25c
commit 309f26c
Showing
22 changed files
with
1,632 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//! Database connection settings. | ||
use crate::values::{ConnectionUri, IsolationLevel, PoolSettings, Secret}; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub const DEFAULT_CONNECTION_URI_VARIABLE: &str = "CONNECTION_URI"; | ||
|
||
/// Database connection settings. | ||
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct DatabaseConnectionSettings { | ||
/// Connection string for a Postgres-compatible database. | ||
pub connection_uri: ConnectionUri, | ||
/// Connection pool settings. | ||
#[serde(default)] | ||
pub pool_settings: PoolSettings, | ||
/// Query isolation level. | ||
#[serde(default)] | ||
pub isolation_level: IsolationLevel, | ||
} | ||
|
||
impl DatabaseConnectionSettings { | ||
pub fn empty() -> Self { | ||
Self { | ||
connection_uri: ConnectionUri(Secret::FromEnvironment { | ||
variable: DEFAULT_CONNECTION_URI_VARIABLE.into(), | ||
}), | ||
pool_settings: PoolSettings::default(), | ||
isolation_level: IsolationLevel::default(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.