gapi-ocaml icon indicating copy to clipboard operation
gapi-ocaml copied to clipboard

Concurrent execution?

Open shonfeder opened this issue 4 years ago • 3 comments

HI! I'm looking for some tips on concurrent execution of API calls. Ideally, it'd be nice to add support for Lwt (I'm happy to put some work into this, if it'd feasible and welcome), but I'm hoping that -- one way or another -- there's a fairy low overhead way of getting current API calls working.

Any pointers/thoughts on this front?

shonfeder avatar Jun 17 '20 20:06 shonfeder

Multi-threading works. The library was written before lwt was available, so it was not considered at the time. Adding lwt support is a lot of work, because it requires rewriting everything in the continuation monad instead of the state monad. I never considered such a rewrite also because I have to support old Ubuntu distros (such as Xenial 16.04) that don't have lwt packaged. In fact, to get lwt support, you have to upgrade ocurl to at least version 0.7.0 that's available only since Bionic 18.04.

astrada avatar Jun 18 '20 06:06 astrada

Thanks for the guidance and info!

I probably don't have the bandwidth to help for a rewrite either, but if I do make any progress in this direction I'll check in to see if you'd be interested.

re: support for older Ubuntu distros, we might try something like functorizing the relevant modules and then creating two different packages, as I think is done for some other libs like, e.g., aws:

aws-s3                   --          Ocaml library for accessing Amazon S3
aws-s3-lwt               --          Ocaml library for accessing Amazon S3 - Lwt version

re: use of threads, it looks maybe this bit of the google-ocamlfuse (and the use of this function elsewhere in the module) might be a good place to look for an example?

shonfeder avatar Jun 19 '20 23:06 shonfeder

re: use of threads, it looks maybe this bit of the google-ocamlfuse (and the use of this function elsewhere in the module) might be a good place to look for an example?

Yes, google-drive-ocamlfuse is the main user of gapi-ocaml, so what you see used there usually works.

astrada avatar Jun 20 '20 16:06 astrada