Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Remove DBIO
Browse files Browse the repository at this point in the history
  • Loading branch information
Julius de Bruijn committed May 20, 2020
1 parent 12d2916 commit 4460975
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 63 deletions.
3 changes: 0 additions & 3 deletions src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ mod queryable;
mod result_set;
mod transaction;

mod dbio;

#[cfg(feature = "mysql")]
pub(crate) mod mysql;
#[cfg(feature = "postgresql")]
Expand All @@ -33,6 +31,5 @@ pub use connection_info::*;

pub(crate) mod metrics;
pub use self::result_set::*;
pub use dbio::DBIO;
pub use queryable::*;
pub use transaction::*;
28 changes: 0 additions & 28 deletions src/connector/dbio.rs

This file was deleted.

62 changes: 31 additions & 31 deletions src/connector/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
use crate::{
ast::{Params, Value},
connector::DBIO,
};
use crate::ast::{Params, Value};
use std::{future::Future, time::Instant};

pub(crate) fn query<'a, F, T, U>(tag: &'static str, query: &'a str, params: &'a [Value], f: F) -> DBIO<'a, T>
pub(crate) async fn query<'a, F, T, U>(
tag: &'static str,
query: &'a str,
params: &'a [Value<'_>],
f: F,
) -> crate::Result<T>
where
F: FnOnce() -> U + Send + 'a,
U: Future<Output = crate::Result<T>> + Send,
{
DBIO::new(async move {
let start = Instant::now();
let res = f().await;
let end = Instant::now();
let start = Instant::now();
let res = f().await;
let end = Instant::now();

if *crate::LOG_QUERIES {
#[cfg(not(feature = "tracing-log"))]
{
info!(
"query: \"{}\", params: {} (in {}ms)",
query,
Params(params),
start.elapsed().as_millis(),
);
}
#[cfg(feature = "tracing-log")]
{
tracing::info!(
query,
item_type = "query",
params = %Params(params),
duration_ms = start.elapsed().as_millis() as u64,
)
}
if *crate::LOG_QUERIES {
#[cfg(not(feature = "tracing-log"))]
{
info!(
"query: \"{}\", params: {} (in {}ms)",
query,
Params(params),
start.elapsed().as_millis(),
);
}
#[cfg(feature = "tracing-log")]
{
tracing::info!(
query,
item_type = "query",
params = %Params(params),
duration_ms = start.elapsed().as_millis() as u64,
)
}
}

timing!(format!("{}.query.time", tag), start, end);
timing!(format!("{}.query.time", tag), start, end);

res
})
res
}
2 changes: 1 addition & 1 deletion src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
pub use crate::ast::*;
#[cfg(any(feature = "sqlite", feature = "mysql", feature = "postgresql"))]
pub use crate::connector::{
ConnectionInfo, Queryable, ResultRow, ResultSet, SqlFamily, Transaction, TransactionCapable, DBIO,
ConnectionInfo, Queryable, ResultRow, ResultSet, SqlFamily, Transaction, TransactionCapable,
};
pub use crate::{col, val, values};

0 comments on commit 4460975

Please sign in to comment.