kiranandcode / petrol

Petrol's an OCaml SQL API made to go FAST.
https://gopiandcode.github.io/petrol/petrol/index.html
Other
109 stars 6 forks source link

Isolate Lwt/Async stuff #2

Open vbmithr opened 1 year ago

vbmithr commented 1 year ago

Hi there, thanks for this project. I'm personally using Core/Async and Postgres_async, I might try it but in the meantime, is it possible that Lwt specific code be well isolated within its own module?

kiranandcode commented 1 year ago

Ah, sorry for the delay. We've recently just added postgres support (mainly just extending the expression DSL to include all the Postgres operators) to Petrol, but I hadn't considered isolating the Lwt stuff.

I think it should be possible. Will try and get it done for the next release.

dangdennis commented 1 year ago

@Gopiandcode If you isolate, I can help out with the eio integration too. Was about to use eio, but I'll use lwt now just for petrol 😄.

Can also assist on the separation work maybe soon too if you haven't started.

kiranandcode commented 1 year ago

@dangdennis Oh, thanks! That would be great. Yep, I haven't started on separating the internals yet, but it should be fairly straightforward. I'll be busy for the next few weeks, but will get started on simplifying it after then --- if you have a fork with some in progress work, I'd be happy to pickup/help from there then.

dangdennis commented 1 year ago

Can you advise on the implementation? The isolation seems straightforward since you've isolated all the lwt work to petrol.ml.

The final result could end up looking similar to how caqti separates libraries for each io runtime. It has an opam package for each: caqti-eio, caqti-lwt, caqti-async. Is it possible to reasonably extract the use of Lwt_result and friends from all the petrol functions such that we don't have to duplicate the exact lines of code?

My initial guess would be to duplicate all the apis such that petrol_eio would have all the same apis but accept a Caqti_eio.Connection instead. But that means a re-implementation of petrol.ml with each io lib.