-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: add custom socket transport support for Postgres and MySQL #4187
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,15 +22,29 @@ impl MySqlConnection { | |
|
|
||
| let stream = handshake?; | ||
|
|
||
| Ok(Self { | ||
| Ok(Self::establish_with_stream(stream, options)) | ||
| } | ||
|
|
||
| pub(crate) async fn establish_with_socket<S: Socket>( | ||
| socket: S, | ||
| options: &MySqlConnectOptions, | ||
| ) -> Result<Self, Error> { | ||
| let do_handshake = DoHandshake::new(options)?; | ||
| let stream = do_handshake.with_socket(socket).await?; | ||
|
|
||
| Ok(Self::establish_with_stream(stream, options)) | ||
| } | ||
|
|
||
| fn establish_with_stream(stream: MySqlStream, options: &MySqlConnectOptions) -> Self { | ||
|
Collaborator
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. This should just be called |
||
| Self { | ||
| inner: Box::new(MySqlConnectionInner { | ||
| stream, | ||
| transaction_depth: 0, | ||
| status_flags: Default::default(), | ||
| cache_statement: StatementCache::new(options.statement_cache_capacity), | ||
| log_settings: options.log_settings.clone(), | ||
| }), | ||
| }) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,12 @@ pub mod decode { | |
|
|
||
| pub use self::decode::Decode; | ||
|
|
||
| /// Networking traits for custom transport implementations. | ||
| pub mod net { | ||
| pub use sqlx_core::io::ReadBuf; | ||
| pub use sqlx_core::net::Socket; | ||
|
Collaborator
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. The Instead, I think we should accept a type that implements the We could either get around this by just having two different methods that use each set of traits, or a single method using a sealed trait that's implemented for adapter types. I'm thinking I'm leaning towards the two different methods, though. |
||
| } | ||
|
|
||
| /// Types and traits for the `query` family of functions and macros. | ||
| pub mod query { | ||
| pub use sqlx_core::query::{Map, Query}; | ||
|
|
||
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.
This function doesn't add anything.