-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(js-connectors): DX, enable hooks for connect()
and disconnect()
#4177
base: main
Are you sure you want to change the base?
Changes from all commits
600d065
dcc263d
71cfa47
a686303
14540b5
e1709df
1188ea8
b49048d
e7b2fc5
3d2bb1b
3a3d123
b2517dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,17 @@ pub trait Queryable: Send + Sync { | |
fn requires_isolation_first(&self) -> bool; | ||
} | ||
|
||
#[async_trait] | ||
pub trait Connectable: Queryable { | ||
async fn connect(&self) -> crate::Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn disconnect(&self) -> crate::Result<()> { | ||
Ok(()) | ||
} | ||
} | ||
|
||
/// A thing that can start a new transaction. | ||
#[async_trait] | ||
pub trait TransactionCapable: Queryable { | ||
|
@@ -128,3 +139,5 @@ macro_rules! impl_default_TransactionCapable { | |
} | ||
|
||
pub(crate) use impl_default_TransactionCapable; | ||
|
||
pub trait JsConnectorLike: TransactionCapable + Connectable {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here, this looks out of place in quaint to me. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
//! A "prelude" for users of the `quaint` crate. | ||
pub use crate::ast::*; | ||
pub use crate::connector::{ | ||
ConnectionInfo, DefaultTransaction, Queryable, ResultRow, ResultSet, SqlFamily, TransactionCapable, | ||
Connectable, ConnectionInfo, DefaultTransaction, Queryable, ResultRow, ResultSet, SqlFamily, TransactionCapable, | ||
}; | ||
pub use crate::{col, val, values}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this trait be moved to js-connectors instead? I don't think quaint's connecteors implement that,
JsConnector
is the only one that needs it.