crclark / foundationdb-haskell

Haskell FFI bindings to the FoundationDB C API
https://crclark.github.io/foundationdb-haskell/
BSD 3-Clause "New" or "Revised" License
36 stars 5 forks source link

Add functions to set up network and database connection(s) separately #49

Open crclark opened 2 years ago

crclark commented 2 years ago

As pointed out here, https://github.com/crclark/foundationdb-haskell/pull/48#issuecomment-1002876006, connecting to multiple databases within a single process is allowed, but setting up multiple network threads is not.

At the moment, we only expose a withFoundationDB function, which sets up the network and connects to the database. Because it does both, it can't be used to connect to multiple databases.

Let's add a separate withNetwork function (with a warning to only call it once) and a separate withDatabase function for advanced use cases when we want to connect to multiple databases.