Skip to content

Commit

Permalink
Merge branch 'main' into fix/tls-builder
Browse files Browse the repository at this point in the history
  • Loading branch information
youxq authored Oct 24, 2024
2 parents 5d7dee2 + 8263a1f commit 28a7c87
Show file tree
Hide file tree
Showing 39 changed files with 414 additions and 230 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/include/rust-wasm-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ runs:
shell: bash
run: |
cargo binstall -y \
wasm-bindgen-cli@0.2.92 \
wasm-bindgen-cli@0.2.93 \
wasm-opt@0.116.0
- name: Install bc
Expand Down
21 changes: 11 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ serde_repr = { version = "0.1.17" }
serde-wasm-bindgen = { version = "0.5" }
tracing = { version = "0.1" }
tsify = { version = "0.4.5" }
wasm-bindgen = { version = "0.2.92" }
wasm-bindgen = { version = "0.2.93" }
wasm-bindgen-futures = { version = "0.4" }
wasm-rs-dbg = { version = "0.1.2", default-features = false, features = ["console-error"] }
wasm-bindgen-test = { version = "0.3.0" }
Expand Down
29 changes: 12 additions & 17 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
inputs = {
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
Expand Down
6 changes: 3 additions & 3 deletions libs/user-facing-errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ impl Error {
}
}

/// Construct a new UnknownError from a `PanicInfo` in a panic hook. `UnknownError`s created
/// with this constructor will have a proper, useful backtrace.
pub fn new_in_panic_hook(panic_info: &std::panic::PanicInfo<'_>) -> Self {
/// Construct a new UnknownError from a [`PanicHookInfo`] in a panic hook. [`UnknownError`]s
/// created with this constructor will have a proper, useful backtrace.
pub fn new_in_panic_hook(panic_info: &std::panic::PanicHookInfo<'_>) -> Self {
let message = panic_info
.payload()
.downcast_ref::<&str>()
Expand Down
6 changes: 5 additions & 1 deletion libs/user-facing-errors/src/schema_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,29 @@ pub struct DatabaseCreationFailed {
code = "P3001",
message = "Migration possible with destructive changes and possible data loss: {destructive_details}"
)]
#[allow(dead_code)]
pub struct DestructiveMigrationDetected {
pub destructive_details: String,
}

/// No longer used.
#[derive(Debug, UserFacingError, Serialize)]
#[user_facing(
code = "P3002",
message = "The attempted migration was rolled back: {database_error}"
)]
#[allow(dead_code)]
struct MigrationRollback {
pub database_error: String,
}

// No longer used.
/// No longer used.
#[derive(Debug, SimpleUserFacingError)]
#[user_facing(
code = "P3003",
message = "The format of migrations changed, the saved migrations are no longer valid. To solve this problem, please follow the steps at: https://pris.ly/d/migrate"
)]
#[allow(dead_code)]
pub struct DatabaseMigrationFormatChanged;

#[derive(Debug, UserFacingError, Serialize)]
Expand Down
11 changes: 9 additions & 2 deletions quaint/src/connector/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ use crate::ast::{Params, Value};
use crosstarget_utils::time::ElapsedTimeCounter;
use std::future::Future;

pub async fn query<'a, F, T, U>(tag: &'static str, query: &'a str, params: &'a [Value<'_>], f: F) -> crate::Result<T>
pub async fn query<'a, F, T, U>(
tag: &'static str,
db_system_name: &'static str,
query: &'a str,
params: &'a [Value<'_>],
f: F,
) -> crate::Result<T>
where
F: FnOnce() -> U + 'a,
U: Future<Output = crate::Result<T>>,
{
let span = info_span!("quaint:query", "db.statement" = %query);
let span =
info_span!("quaint:query", "db.system" = db_system_name, "db.statement" = %query, "otel.kind" = "client");
do_query(tag, query, params, f).instrument(span).await
}

Expand Down
7 changes: 4 additions & 3 deletions quaint/src/connector/mssql/native/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use tokio_util::compat::{Compat, TokioAsyncWriteCompatExt};
pub use tiberius;

static SQL_SERVER_DEFAULT_ISOLATION: IsolationLevel = IsolationLevel::ReadCommitted;
const DB_SYSTEM_NAME: &str = "mssql";

#[async_trait]
impl TransactionCapable for Mssql {
Expand Down Expand Up @@ -130,7 +131,7 @@ impl Queryable for Mssql {
}

async fn query_raw(&self, sql: &str, params: &[Value<'_>]) -> crate::Result<ResultSet> {
metrics::query("mssql.query_raw", sql, params, move || async move {
metrics::query("mssql.query_raw", DB_SYSTEM_NAME, sql, params, move || async move {
let mut client = self.client.lock().await;

let mut query = tiberius::Query::new(sql);
Expand Down Expand Up @@ -193,7 +194,7 @@ impl Queryable for Mssql {
}

async fn execute_raw(&self, sql: &str, params: &[Value<'_>]) -> crate::Result<u64> {
metrics::query("mssql.execute_raw", sql, params, move || async move {
metrics::query("mssql.execute_raw", DB_SYSTEM_NAME, sql, params, move || async move {
let mut query = tiberius::Query::new(sql);

for param in params {
Expand All @@ -213,7 +214,7 @@ impl Queryable for Mssql {
}

async fn raw_cmd(&self, cmd: &str) -> crate::Result<()> {
metrics::query("mssql.raw_cmd", cmd, &[], move || async move {
metrics::query("mssql.raw_cmd", DB_SYSTEM_NAME, cmd, &[], move || async move {
let mut client = self.client.lock().await;
self.perform_io(client.simple_query(cmd)).await?.into_results().await?;
Ok(())
Expand Down
8 changes: 5 additions & 3 deletions quaint/src/connector/mysql/native/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ impl MysqlUrl {
}
}

const DB_SYSTEM_NAME: &str = "mysql";

/// A connector interface for the MySQL database.
#[derive(Debug)]
pub struct Mysql {
Expand Down Expand Up @@ -195,7 +197,7 @@ impl Queryable for Mysql {
}

async fn query_raw(&self, sql: &str, params: &[Value<'_>]) -> crate::Result<ResultSet> {
metrics::query("mysql.query_raw", sql, params, move || async move {
metrics::query("mysql.query_raw", DB_SYSTEM_NAME, sql, params, move || async move {
self.prepared(sql, |stmt| async move {
let mut conn = self.conn.lock().await;
let rows: Vec<my::Row> = conn.exec(&stmt, conversion::conv_params(params)?).await?;
Expand Down Expand Up @@ -280,7 +282,7 @@ impl Queryable for Mysql {
}

async fn execute_raw(&self, sql: &str, params: &[Value<'_>]) -> crate::Result<u64> {
metrics::query("mysql.execute_raw", sql, params, move || async move {
metrics::query("mysql.execute_raw", DB_SYSTEM_NAME, sql, params, move || async move {
self.prepared(sql, |stmt| async move {
let mut conn = self.conn.lock().await;
conn.exec_drop(stmt, conversion::conv_params(params)?).await?;
Expand All @@ -297,7 +299,7 @@ impl Queryable for Mysql {
}

async fn raw_cmd(&self, cmd: &str) -> crate::Result<()> {
metrics::query("mysql.raw_cmd", cmd, &[], move || async move {
metrics::query("mysql.raw_cmd", DB_SYSTEM_NAME, cmd, &[], move || async move {
self.perform_io(|| async move {
let mut conn = self.conn.lock().await;
let mut result = cmd.run(&mut *conn).await?;
Expand Down
Loading

0 comments on commit 28a7c87

Please sign in to comment.