paurkedal / ocaml-caqti

Cooperative-threaded access to relational data
https://paurkedal.github.io/ocaml-caqti/index.html
GNU Lesser General Public License v3.0
312 stars 36 forks source link

Per-Connection Configuration #89

Closed paurkedal closed 8 months ago

paurkedal commented 2 years ago

Issue #86 highlighted the need for a way to configure Caqti connections, apart from when can reasonably be fitted into the endpoint URL. The upcoming PGX support (#38) will also need a way to configure TLS, which calls for another solution.

Considering generic TLS configurations, note that drivers based on C bindings accepts file paths while the tls library accepts in-memory cryptographic content. A unified TLS configuration would therefore involve loading and storing files depending on what is provided and what is needed. A unified configuration will be even more challenging if we wish to support a road range of driver-specific parameters.

A better option may therefore be to use an open type for the configuration keys and a hmap(-like) value to store them. This would allow defining configuration keys in sub-libraries, e.g. using Tls.Config.client to configure the usage of the tls library, while avoiding the dependency in the core library.

paurkedal commented 2 years ago

The gmap library provides an arguably simpler interface than hmap, but the difference is essential here, since gmap is better suited for closed key types.

paurkedal commented 1 year ago

I pushed a sketch to the config-2022 branch. Though it is more or less complete functionality-wise, I am less sure about the API, so I'm parking this for now to avoid committing to the design before it is needed.

paurkedal commented 8 months ago

A fairly light solution was chosen, covering only TLS parameters, at least for now.