Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Remove context calls for create database #713

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions sqld/src/hrana/http/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,7 @@ pub async fn acquire<'srv, D: Connection>(
stream
}
None => {
let db = connection_maker
.create()
.await
.context("Could not create a database connection")?;
let db = connection_maker.create().await?;

let mut state = server.stream_state.lock();
let stream = Box::new(Stream {
Expand Down
5 changes: 2 additions & 3 deletions sqld/src/hrana/ws/session.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashMap;
use std::sync::Arc;

use anyhow::{anyhow, bail, Context as _, Result};
use anyhow::{anyhow, bail, Result};
use futures::future::BoxFuture;
use tokio::sync::{mpsc, oneshot};

Expand Down Expand Up @@ -195,8 +195,7 @@ pub(super) async fn handle_request<F: MakeNamespace>(
.with_authenticated(namespace, authenticated, |ns| ns.db.connection_maker())
.await?
.create()
.await
.context("Could not create a database connection")?;
.await?;
stream.db = Some(Arc::new(db));
Ok(proto::Response::OpenStream(proto::OpenStreamResp {}))
});
Expand Down
5 changes: 1 addition & 4 deletions sqld/src/http/user/hrana_over_http_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ where
let req_body = serde_json::from_slice(&req_body)
.map_err(|e| hrana::ProtocolError::JsonDeserialize { source: e })?;

let db = db_factory
.create()
.await
.context("Could not create a database connection")?;
let db = db_factory.create().await?;
let resp_body = f(db, req_body).await?;

Ok(json_response(hyper::StatusCode::OK, &resp_body))
Expand Down