Tom Larkworthy
12/03/2021, 8:08 AMKonrad Hinsen
12/03/2021, 10:06 AMTom Larkworthy
12/03/2021, 10:57 AM//server
remoteFunction = serve((x) => x*x), options)
answer = await remoteFunction(5)
I think there is enough wiggle room for people to add their own abstractions, and because the result is a promise we can put in network errors.
Would this cover your usecase? (if anyone knows of any simple RPC abstractions I should draw inspiration from I would love to see)Konrad Hinsen
12/08/2021, 1:27 PMTom Larkworthy
12/08/2021, 1:54 PMKonrad Hinsen
12/09/2021, 8:02 AMTom Larkworthy
12/09/2021, 8:18 AMI need to set up some server first, right?No! The webcode runtime is a generic container [1] that knows how to run notebooks (it has puppeteer inside it). So that one container runs all the notebooks. If you looks at the outbound requests to webcode, the URL encodes which notebook to dynamically lookup. The Oath implementation is at the application level in a notebook. Often, you also need persistence, so I use Firebase as that works well with browser. The server is pupeteer, i.e., also a browser. So if you want to run your own Oauth server you need to bring-your-own-firebase after forking my notebook. [1] https://github.com/endpointservices/webcode.run/blob/main/Dockerfile
practically useful server applications can do without any preinstalled dependencies.All dependencies come in via normal Javascript imports. The major limitations is that many javascript dependencies are node only, but that is changing to ES6 modules (if no other reason than to support Deno). It's kind of like Deno but when you mix in Observablehq you have a whole IDE and its trivial to switch the execution from serverside to clientside and vice versa as they are all just browsers. When you turn on "live debugging", a tunnel is setup like ngrok, that tunnels production traffic to the developers machine. The developers browser processes the request (giving opportunity for debugging) and sends back the response. This is how code changes are immediate with 0 latency, the developers latest code is the server when in live mode. This is enabled by the browser being the normalized environment.
Konrad Hinsen
12/10/2021, 9:40 AMTom Larkworthy
12/10/2021, 6:52 PMFlorian Schulz
12/11/2021, 5:51 AMTom Larkworthy
12/11/2021, 7:22 AMWhat if you write a crazy service that causes way too much load?1. Its rate limited but also 2. I hit their "embed" endpoint which is hosted on a CDN and targeted at 3rd party embedding on external websites.
Do you think this can fly for real world projects?Yes! Most features are implemented as webcode, for example, the secrets API is webcode hosted and wraps Google Secret Manager The latency prober I use to measure performance is also webcode implemented. We have got hot performance down to 30ms! It's not quite as fast as a dedicated lambda but its in an acceptable engineering trade off zone IMHO (devX for a little perf hit).
is there a way to host/install the environment on your own cloud infrastructure of choice?Yes it is technically possible, if you look at the API options, you can set the remote and region, so you can host your own webcode.run container (and you can set it to localhost for testing). I have not documented the self hosting path yet, but I would like to encourage it when I have some demand for that. The runtime is in a single container, so it should be fairly portable. I use Cloud Run.
Is only the source code (as text) from Observable used but the actual executing server is deployed elsewhere?Yeah Observable is the code hosting platform + reactive runtime. The compute is external (webcode.run uses Google Cloud Run but any docker hosting service "should" work, I am thinking about migrating to fly.io). The realtime user control plane is Firestore though, and that is unlikely to be switchable. I would say the state of it is still a little pre-production. I am not providing an SLO or carrying a pager yet, but it is actively monitored and robustness has hugely improved in the last 6 months. I think it's amazing for API glue, but it struggles when you need a filesystem, like technically it can be a webserver, but uploading static assets is kinda hard so it can only really do small util endpoints at the moment.
Florian Schulz
12/18/2021, 6:12 AMTom Larkworthy
12/18/2021, 9:27 AM