From aae0f0595061ad32960541c532930be0e5af51f2 Mon Sep 17 00:00:00 2001 From: Mateus Cruz Date: Tue, 6 Feb 2024 00:59:54 -0300 Subject: add lock --- lib/handler.ml | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/handler.ml') diff --git a/lib/handler.ml b/lib/handler.ml index 121a0c5..4babe6e 100644 --- a/lib/handler.ml +++ b/lib/handler.ml @@ -8,6 +8,10 @@ let valid_debit value limit balance = let create_transaction client_id (db_pool : Query.pool) (request : Request.t) = Caqti_eio.Pool.use (fun conn -> + let module C = (val conn : Rapper_helper.CONNECTION) in + C.with_transaction + @@ fun () -> + let _ = Query.lock client_id conn in let client_opt = Option.join @@ Result.to_option @@ Query.find_client client_id conn in -- cgit v1.2.3