And these are all the primitives that platforms need to build so that you can leverage it however you actually want. So, when all of this is actually done properly, you know, ideally you should just be able to say, okay, I want to just resume an older instance of something that I was working on, and here we go. The same state that we were actually in, we are able to get back to. So, let's look at under the hood and try to understand, well, how does this look from your point of view of you actually using some sandbox? So, it's actually this whole demo that we actually just looked at. In its simplest form, it's actually just, you know, eight lines of code. Let's break it down a bit.
The first one is isolation. So, every session, it gets its own VM. You can think about, you know, separate sandboxes per user, per org. There's all sorts of things that you could actually do. And then there are all the different methods that actually allows you to start processes, wait for a particular process to be ready, read and write files, you know, whenever you actually want to. Then the networking bit, which we spoke about, all the things that we addressed earlier in the networking section can actually just be one line. You get back a URL, and that's all you need to think about. And finally, you want to do some persistence. In this demo, frankly, all I'm doing is just storing my code in a bucket, but, you know, you could also opt into some of the more advanced strategies depending on the use cases like we discussed.
So, this is what, at least from a Cloudflare context where I work, the way this whole architecture looks like can be thought about as, you know, requests from the agent and the browser is reaching the edge, the worker. And from there, there's a durable object, which basically, the most important thing that it offers in this context is it's globally uniquely addressable, which is something that we wanted. We want to reach a very specific sandbox, right? So, the durable object makes sure that you're able to do the routing, and then you are able to reach the particular sandbox, and within the sandbox, you do all the things that you want to do.
Comments