This commit is contained in:
parent
de9119d40b
commit
9cf8ec8367
1 changed files with 2 additions and 1 deletions
|
|
@ -2,13 +2,14 @@
|
||||||
[connect_pool] with parameter [?post_connect] for preflight *)
|
[connect_pool] with parameter [?post_connect] for preflight *)
|
||||||
let db_conn =
|
let db_conn =
|
||||||
let f Env.{ sw; stack; tcp; dns; fs= _ } =
|
let f Env.{ sw; stack; tcp; dns; fs= _ } =
|
||||||
|
Logs.info (fun m -> m "Connecting to database ...");
|
||||||
let db_uri = Config.Exchangedb_postgres.config in
|
let db_uri = Config.Exchangedb_postgres.config in
|
||||||
match Caqti_mnet.connect ~sw stack tcp dns db_uri with
|
match Caqti_mnet.connect ~sw stack tcp dns db_uri with
|
||||||
| Error err ->
|
| Error err ->
|
||||||
Fmt.failwith "Database connection failure: %a." Caqti_error.pp err
|
Fmt.failwith "Database connection failure: %a." Caqti_error.pp err
|
||||||
| Ok conn ->
|
| Ok conn ->
|
||||||
let () = Pg.preflight conn in
|
let () = Pg.preflight conn in
|
||||||
Logs.info (fun m -> m "database connection initialized");
|
Logs.info (fun m -> m "... connection done.");
|
||||||
conn
|
conn
|
||||||
in
|
in
|
||||||
let finally (module Conn : Pg.CONN) = Conn.disconnect () in
|
let finally (module Conn : Pg.CONN) = Conn.disconnect () in
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue