Skip to content

Commit 53f6e03

Browse files
impl before_commit evt
1 parent 9e0b8e7 commit 53f6e03

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/modules/db/sqlx/mod.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,22 @@ unsafe extern "C" fn fn_transaction_commit(
16751675

16761676
let transaction = with_transaction(proxy_instance_id, |tx| tx.clone());
16771677

1678+
let before_commit_res = q_ctx.dispatch_proxy_event(
1679+
&["greco", "db", "sqlx"],
1680+
"Transaction",
1681+
&proxy_instance_id,
1682+
"before_commit",
1683+
&q_ctx.create_null().unwrap(),
1684+
);
1685+
match before_commit_res {
1686+
Ok(_) => {}
1687+
Err(e) => {
1688+
log::error!("dispatch_before_commit failed due to {e}");
1689+
return q_ctx
1690+
.report_ex(format!("dispatch_before_commit failed due to {e}").as_str());
1691+
}
1692+
}
1693+
16781694
let promise = q_ctx.create_resolving_promise_async(
16791695
async move {
16801696
// produce
@@ -1697,14 +1713,13 @@ unsafe extern "C" fn fn_transaction_commit(
16971713
);
16981714
match promise {
16991715
Ok(p) => p.clone_value_incr_rc(),
1700-
Err(_) => {
1701-
// todo report error?
1702-
new_undefined()
1716+
Err(e) => {
1717+
log::error!("could not create promise due to {e}");
1718+
q_ctx.report_ex(format!("could not create promise due to{e}").as_str())
17031719
}
17041720
}
17051721
} else {
1706-
// todo report error?
1707-
new_undefined()
1722+
q_ctx.report_ex("could not find tx instance by id")
17081723
}
17091724
})
17101725
}

0 commit comments

Comments
 (0)