-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change read cert to async (#175)
* feat(driver): wrap Connection with Client * fix: change read cert to async * fix: add license header for pyi * fix: update nodejs binding
- Loading branch information
Showing
19 changed files
with
133 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
# Copyright 2021 Datafuse Labs | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
class AsyncDatabendDriver: | ||
def __init__(self, dsn: str): ... # NOQA | ||
async def exec(self, sql: str) -> int: ... # NOQA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,7 @@ pub struct APIClient { | |
} | ||
|
||
impl APIClient { | ||
pub fn from_dsn(dsn: &str) -> Result<Self> { | ||
pub async fn from_dsn(dsn: &str) -> Result<Self> { | ||
let u = Url::parse(dsn)?; | ||
let mut client = Self::default(); | ||
if let Some(host) = u.host_str() { | ||
|
@@ -166,7 +166,7 @@ impl APIClient { | |
#[cfg(any(feature = "rustls", feature = "native-tls"))] | ||
if scheme == "https" { | ||
if let Some(ref ca_file) = client.tls_ca_file { | ||
let cert_pem = std::fs::read(ca_file)?; | ||
let cert_pem = tokio::fs::read(ca_file).await?; | ||
let cert = reqwest::Certificate::from_pem(&cert_pem)?; | ||
client.cli = HttpClient::builder().add_root_certificate(cert).build()?; | ||
} | ||
|
@@ -543,10 +543,10 @@ impl Default for APIClient { | |
mod test { | ||
use super::*; | ||
|
||
#[test] | ||
fn parse_dsn() -> Result<()> { | ||
#[tokio::test] | ||
async fn parse_dsn() -> Result<()> { | ||
let dsn = "databend://username:[email protected]/test?wait_time_secs=10&max_rows_in_buffer=5000000&max_rows_per_page=10000&warehouse=wh&sslmode=disable"; | ||
let client = APIClient::from_dsn(dsn)?; | ||
let client = APIClient::from_dsn(dsn).await?; | ||
assert_eq!(client.host, "app.databend.com"); | ||
assert_eq!(client.endpoint, Url::parse("http://app.databend.com:80")?); | ||
assert_eq!(client.user, "username"); | ||
|
@@ -566,18 +566,18 @@ mod test { | |
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn parse_encoded_password() -> Result<()> { | ||
#[tokio::test] | ||
async fn parse_encoded_password() -> Result<()> { | ||
let dsn = "databend://username:3a%40SC(nYE1k%3D%7B%7BR@localhost"; | ||
let client = APIClient::from_dsn(dsn)?; | ||
let client = APIClient::from_dsn(dsn).await?; | ||
assert_eq!(client.password, Some("3a@SC(nYE1k={{R".to_string())); | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn parse_special_chars_password() -> Result<()> { | ||
#[tokio::test] | ||
async fn parse_special_chars_password() -> Result<()> { | ||
let dsn = "databend://username:3a@SC(nYE1k={{R@localhost:8000"; | ||
let client = APIClient::from_dsn(dsn)?; | ||
let client = APIClient::from_dsn(dsn).await?; | ||
assert_eq!(client.password, Some("3a@SC(nYE1k={{R".to_string())); | ||
Ok(()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.