package postgresql

  1. Overview
  2. Docs

Module Postgresql.ConnectionSource

Connection parametrized by the type of mutex used.

If you are using your own wrapper around connection, you could for instance use this kind of code:

  module Check = struct
    type t = bool Atomic.t

    let create () = Atomic.make false

    let lock m =
      if not (Atomic.compare_and_set m false true) then
        failwith "Concurrent use of a Postgres connection (at lock)"

    let unlock m =
      if not (Atomic.compare_and_set m true false) then
        failwith
          "Concurrent use of a Postgres connection (at unlock, impossible \
           ?)"
  end

  module Postgresql = struct
    include Postgresql
    include Connection (Check)
  end

Parameters

module _ : Mutex

Signature

Sourceclass connection : ?host:string -> ?hostaddr:string -> ?port:string -> ?dbname:string -> ?user: string -> ?password:string -> ?options:string -> ?tty:string -> ?requiressl: string -> ?conninfo:string -> ?startonly:bool -> unit -> connection_class