repl icon indicating copy to clipboard operation
repl copied to clipboard

Fable as a Service (Repl)

Open citymeterio opened this issue 7 years ago • 6 comments

I'm struggling with building fable-splitter. It requires to be comfortable with the stack (npm, yarn, dotnet, webpack, fake, packet) and I'm not yet there. But if I 'm not mistaken I have noticed once on some video that somebody was running F# script through fable-repl online with the POST request. Is this feasible? If not could you Guys think about such a solution? I really need the simplest possible "fsx2js for the PoC I'm creating for my team leader/product owner.

citymeterio avatar Nov 21 '18 22:11 citymeterio

Currently the fable-repl is just static files so there's no backend service. I guess it shouldn't be difficult to create a dotnet/node simple server to provide such an end point, but you'll have to deploy it somewhere by yourself as we don't have a server infrastructure for Fable at the moment. The tricky part is you need to keep the FSharpChecker alive to avoid huge load times, so using a serverless function is not an option.

@nojaf and @jindraivanek have created similar REST services, maybe they can give some hints.

alfonsogarciacaro avatar Nov 21 '18 23:11 alfonsogarciacaro

Even a serverless function can have static variables. It would not cold start with every call. It only cold starts when it's provisioning a new instance and that's rare. But in these cases you definitely have slow down. So if you want to guarantee fast results for every single call then you need something else.

forki avatar Nov 22 '18 05:11 forki

Hmm, its not impossible as mentioned above, however the things we did always had a cold start. Alfonso is talking about ast-viewer and fantomas online.

nojaf avatar Nov 22 '18 06:11 nojaf

I was able to use fable-splitter with Fulma minimal template. This combination seems to be the simplest for a laic. Now I assume it shouldn't be a problem to update F# script file on the fly and trigger fable-splitter command having deamon always being alive. I only need this strange setup for the PoC. Then I plan to dive into the real internals or other possibilities

citymeterio avatar Nov 22 '18 08:11 citymeterio

I wrote blog post about my setup: http://jindraivanek.gitlab.io/blog/2018-10-22-FAKE-continuous-deployment/

Cold vs hot start is big diff, something like 5s vs 0.5s.

After I figured out deployment process, I didn't have any problem with server, it just works(TM). However as my server have only 1GB RAM, bigger input can bring the service down, so I limit input size to 10kB. Code from F# compiler is good test case for this :)

jindraivanek avatar Nov 22 '18 08:11 jindraivanek

Thanks @jindraivanek , I will test it as well. I do not have any hardware limitations from the server point of view

citymeterio avatar Nov 22 '18 08:11 citymeterio