Skip to content

Commit

Permalink
Restore preservation of session configuration across reconnects (#1183)
Browse files Browse the repository at this point in the history
This regressed in #1156
  • Loading branch information
elprans authored Dec 4, 2023
1 parent afedca7 commit a3b4401
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub fn main(options: Options, cfg: Config) -> Result<(), anyhow::Error> {
pub async fn _main(options: Options, mut state: repl::State, cfg: Config)
-> anyhow::Result<()>
{
state.reconnect().await?;
state.connect().await?;
if let Some(config_path) = &cfg.file_name {
echo!(
format_args!("Applied {} configuration file",
Expand Down
14 changes: 14 additions & 0 deletions src/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,23 @@ impl PromptRpc {
}

impl State {
pub async fn connect(&mut self) -> anyhow::Result<()> {
let db = self.conn_params.get()?.database().to_owned();
self.try_connect(&db).await?;
Ok(())
}
pub async fn reconnect(&mut self) -> anyhow::Result<()> {
let db = self.conn_params.get()?.database().to_owned();
let cur_state = self.edgeql_state.clone();
let cur_state_desc = self.edgeql_state_desc.clone();
self.try_connect(&db).await?;
if let Some(conn) = &mut self.connection {
if cur_state_desc == self.edgeql_state_desc {
conn.set_state(cur_state);
} else {
eprintln!("Discarding session configuration because server configuration layout has changed.");
}
}
Ok(())
}
pub async fn set_idle_transaction_timeout(&mut self) -> anyhow::Result<()> {
Expand Down

0 comments on commit a3b4401

Please sign in to comment.