Skip to content

Commit

Permalink
chore: fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
zitsen committed Nov 29, 2022
1 parent 2063d9f commit 7d600c0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
4 changes: 3 additions & 1 deletion taos-query/src/common/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ mod tests {
for prec in [Millisecond, Microsecond, Nanosecond] {
let ts = Timestamp::new(0, prec);
assert!(ts.as_raw_i64() == 0);
assert!(ts.to_naive_datetime() == chrono::NaiveDateTime::from_timestamp(0, 0));
assert!(
ts.to_naive_datetime() == chrono::NaiveDateTime::from_timestamp_opt(0, 0).unwrap()
);
}
}

Expand Down
19 changes: 8 additions & 11 deletions taos-ws/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![recursion_limit = "256"]
use std::fmt::{Debug, Display};
use std::time::Duration;

use once_cell::sync::OnceCell;

Expand All @@ -10,8 +9,6 @@ use taos_query::{DsnError, IntoDsn, TBuilder};
mod stmt;
pub use stmt::Stmt;

use taos_query::prelude::tokio;

// pub mod tmq;
pub mod consumer;
pub use consumer::{Consumer, TmqBuilder};
Expand All @@ -34,7 +31,7 @@ pub struct TaosBuilder {
addr: String,
auth: WsAuth,
database: Option<String>,
timeout: Duration,
// timeout: Duration,
}

#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -127,19 +124,19 @@ impl TaosBuilder {
None => "localhost:6041".to_string(),
};

let timeout = dsn
.params
.remove("timeout")
.and_then(|s| parse_duration::parse(&s).ok())
.unwrap_or(Duration::from_secs(60 * 5)); // default to 5m
// let timeout = dsn
// .params
// .remove("timeout")
// .and_then(|s| parse_duration::parse(&s).ok())
// .unwrap_or(Duration::from_secs(60 * 5)); // default to 5m

if let Some(token) = token {
Ok(TaosBuilder {
scheme,
addr,
auth: WsAuth::Token(token),
database: dsn.subject,
timeout,
// timeout,
})
} else {
let username = dsn.username.unwrap_or_else(|| "root".to_string());
Expand All @@ -149,7 +146,7 @@ impl TaosBuilder {
addr,
auth: WsAuth::Plain(username, password),
database: dsn.subject,
timeout,
// timeout,
})
}
}
Expand Down
11 changes: 4 additions & 7 deletions taos-ws/src/query/asyn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use taos_query::common::{Field, Precision, RawBlock, RawMeta};
use taos_query::prelude::{Code, RawError};
use taos_query::util::InlinableWrite;
use taos_query::{
block_in_place_or_global, AsyncFetchable, AsyncQueryable, DeError, Dsn, DsnError, IntoDsn,
block_in_place_or_global, AsyncFetchable, AsyncQueryable, DeError, DsnError, IntoDsn,
};
use thiserror::Error;

Expand Down Expand Up @@ -69,7 +69,6 @@ struct WsQuerySender {
results: Arc<QueryResMapper>,
sender: WsSender,
queries: QueryAgent,
timeout: Duration,
}

impl WsQuerySender {
Expand All @@ -80,7 +79,7 @@ impl WsQuerySender {
async fn send_recv(&self, msg: WsSend) -> Result<WsRecvData> {
let send_timeout = Duration::from_millis(1000);
let req_id = msg.req_id();
let (tx, mut rx) = query_channel();
let (tx, rx) = query_channel();

self.queries.insert(req_id, tx);

Expand Down Expand Up @@ -461,8 +460,8 @@ async fn read_queries(

let mut keys = Vec::new();
for e in queries_sender.iter() {
keys.push(*e.key());
}
keys.push(*e.key());
}
// queries_sender
// .for_each_async(|k, _| {
// keys.push(*k);
Expand Down Expand Up @@ -609,7 +608,6 @@ impl WsTaos {
sender: ws_cloned,
queries: queries2_cloned,
results,
timeout: info.timeout,
},
})
}
Expand Down Expand Up @@ -883,7 +881,6 @@ impl taos_query::Fetchable for ResultSet {
}

fn fetch_raw_block(&mut self) -> StdResult<Option<RawBlock>, Self::Error> {

block_in_place_or_global(self.fetch())
}
}
Expand Down

0 comments on commit 7d600c0

Please sign in to comment.