Skip to content

Commit

Permalink
feat: fixed messages and renamed config vars
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosvdr committed Oct 3, 2024
1 parent 1fbecce commit 0545a72
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
10 changes: 5 additions & 5 deletions config/maximal-config-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ port = 7300
postgres_url = "postgres://postgres@postgres:5432/postgres"
# You can also use the following fields to specify the connection details separately.
# either use `postgres_url` or the following fields.
postgres_host = "postgres-host"
postgres_port = 5432
postgres_user = "user"
postgres_password = "pwd"
postgress_db = "postgres"
host = "postgres-host"
port = 5432
user = "user"
password = "pwd"
database = "postgres"

[graph_node]
# URL to your graph-node's query endpoint
Expand Down
10 changes: 5 additions & 5 deletions config/minimal-config-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ operator_mnemonic = "celery smart tip orange scare van steel radio dragon joy al
postgres_url = "postgres://postgres@postgres:5432/postgres"
# You can also use the following fields to specify the connection details separately.
# either use `postgres_url` or the following fields.
postgres_host = "postgres-host"
postgres_port = 5432
postgres_user = "user"
postgres_password = "pwd"
postgress_db = "postgres"
host = "postgres-host"
port = 5432
user = "user"
password = "pwd"
database = "postgres"

[graph_node]
# URL to your graph-node's query endpoint
Expand Down
13 changes: 8 additions & 5 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ pub enum DatabaseConfig {
},
}
impl DatabaseConfig {
pub fn get_formated_postgres_url(&self) -> Url {
pub fn get_formated_postgres_url(self) -> Url {
match self {
DatabaseConfig::PostgresUrl { postgres_url } => postgres_url.clone(),
DatabaseConfig::PostgresUrl { postgres_url } => postgres_url,
DatabaseConfig::PostgresVars {
host,
port,
Expand All @@ -172,11 +172,14 @@ impl DatabaseConfig {
database,
} => {
let postgres_url_str = format!("postgres://{}@{}/{}", user, host, database);
let mut postgres_url = Url::parse(&postgres_url_str).unwrap();
let mut postgres_url =
Url::parse(&postgres_url_str).expect("Failed to parse database_url");
postgres_url
.set_password(password.as_deref())
.expect("url is wrong");
postgres_url.set_port(*port).expect("url is wrong");
.expect("Failed to set password for database");
postgres_url
.set_port(port)
.expect("Failed to set port for database");
postgres_url
}
}
Expand Down

0 comments on commit 0545a72

Please sign in to comment.