implement empty client

This commit is contained in:
OMGeeky
2023-04-15 16:22:46 +02:00
parent 655df48ba3
commit fcbaf6926c
3 changed files with 25 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "google_bigquery_v2"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -5,6 +5,7 @@ use google_bigquery2::hyper::client::HttpConnector;
use google_bigquery2::hyper_rustls::HttpsConnector;
use google_bigquery2::Bigquery;
use google_bigquery2::{hyper, hyper_rustls, oauth2};
use google_bigquery2::client::NoToken;
#[derive(Clone)]
pub struct BigqueryClient {
@@ -21,16 +22,26 @@ impl Default for BigqueryClient {
impl BigqueryClient {
pub fn empty() -> BigqueryClient {
todo!()
let auth: NoToken = NoToken::default();
let client = Bigquery::new(
hyper::Client::builder().build(
hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.https_or_http()
.enable_http1()
.enable_http2()
.build(),
),
auth,
);
BigqueryClient {
client,
project_id: "".to_string(),
dataset_id: "".to_string(),
}
}
}
//TODO: check if this unsafe impl is needed
unsafe impl Send for BigqueryClient {}
//TODO: check if this unsafe impl is needed
unsafe impl Sync for BigqueryClient {}
impl BigqueryClient {
pub async fn new<S: Into<String>>(
project_id: S,

View File

@@ -217,6 +217,12 @@ async fn test_select_limit_1() {
assert_eq!(q.len(), 1);
}
#[test]
fn test_empty_client(){
let empty_client = BigqueryClient::empty();
debug!("empty client: {:?}", empty_client);
}
fn init_logger() {
let global_level = LevelFilter::Info;
let own_level = LevelFilter::Trace;