revery-ui / revery

:zap: Native, high-performance, cross-platform desktop apps - built with Reason!
https://www.outrunlabs.com/revery/
MIT License
8.06k stars 196 forks source link

Fetch API, v2 #996

Open bryphe opened 4 years ago

bryphe commented 4 years ago

@lessp has done some awesome work in pioneering a fetch API for us through https://github.com/lessp/fetch

Unfortunately, we can't use it in Onivim 2 yet - I would love to be able to, because we could remove this node-script-shim that we have today: https://github.com/onivim/oni2/blob/63e3159b0f45bed017251e4f35465bcb383a1b50/src/Service/Net/Service_Net.re#L69

There are a couple of blockers: 1) We need to ensure the fetch strategy works on Windows (and has CI tests for it) 2) Ideally, the fetch strategy should use libuv as the back-end - I envision Revery / Onivim to use libuv as the event loop. Might be easier once there is a libuv-lwt engine.

WhoAteDaCake commented 3 years ago

What about using the existing libuv ocaml bindings ? https://github.com/aantron/luv

lessp commented 3 years ago

What about using the existing libuv ocaml bindings ? https://github.com/aantron/luv

That's absolutely an alternative, I believe Luv is already used in Oni2. For a viable HTTP(S)-client we'd need to hook it up with something like ocaml-tls. 🙂

bryphe commented 3 years ago

Definitely - luv + a http/https client built on-top would be perfect

zbaylin commented 3 years ago

@bryphe and I discussed using ocurl the other day as a solution to this problem. Pros

Cons

I'm going to investigate how hard it would be to write an luv wrapper on top of the existing ocurl code. I think it would be fairly similar to the Lwt code 🤞

zbaylin commented 3 years ago

I made this as a proof of concept: https://github.com/zbaylin/ocurl-luv-test -- the only issues I'm running into as of now is converting a Unix.file_descr to an Luv.Os_fd.Socket.t. Unfortunately, Obj.magic doesn't seem to work and the Unix tools were removed from Luv in order to not depend on Unix. Once I find a fix I think ocurl will definitely be a viable option for this!

bryphe commented 3 years ago

Awesome progress @zbaylin !

bryphe commented 3 years ago

Unfortunately, Obj.magic doesn't seem to work and the Unix tools were removed from Luv in order to not depend on Unix

I wonder if we can bring these back in a fork, or just in Revery?