Skip to content

Commit

Permalink
Make standbys optional
Browse files Browse the repository at this point in the history
  • Loading branch information
photino committed Apr 21, 2023
1 parent eddec54 commit 116fda3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 0 additions & 2 deletions zino-core/src/connector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ mod connector_mysql;
mod connector_postgres;
#[cfg(feature = "connector-sqlite")]
mod connector_sqlite;
#[cfg(feature = "connector-taos")]
mod connector_taos;

#[cfg(any(
feature = "connector-mssql",
Expand Down
28 changes: 15 additions & 13 deletions zino-core/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,21 @@ impl State {
.expect("the `main.port` field should be an integer");
listeners.push((main_host, main_port).into());

// Standbys.
let standbys = config
.get_array("standby")
.expect("the `standby` field should be an array of tables");
for standby in standbys.iter().filter_map(|v| v.as_table()) {
let standby_host = standby
.get_str("host")
.and_then(|s| s.parse::<IpAddr>().ok())
.expect("the `standby.host` field should be a str");
let standby_port = standby
.get_u16("port")
.expect("the `standby.port` field should be an integer");
listeners.push((standby_host, standby_port).into());
// Optional standbys.
if config.contains_key("standy") {
let standbys = config
.get_array("standby")
.expect("the `standby` field should be an array of tables");
for standby in standbys.iter().filter_map(|v| v.as_table()) {
let standby_host = standby
.get_str("host")
.and_then(|s| s.parse::<IpAddr>().ok())
.expect("the `standby.host` field should be a str");
let standby_port = standby
.get_u16("port")
.expect("the `standby.port` field should be an integer");
listeners.push((standby_host, standby_port).into());
}
}

listeners
Expand Down

0 comments on commit 116fda3

Please sign in to comment.