petrol icon indicating copy to clipboard operation
petrol copied to clipboard

Isolate Lwt/Async stuff

Open vbmithr opened this issue 2 years ago • 4 comments

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?

vbmithr avatar Feb 03 '23 21:02 vbmithr

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.

kiranandcode avatar Mar 17 '23 13:03 kiranandcode

@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.

dangdennis avatar May 26 '23 15:05 dangdennis

@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.

kiranandcode avatar May 31 '23 00:05 kiranandcode

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.

dangdennis avatar May 31 '23 01:05 dangdennis