 Hello, my name is Connor Hicks. I am a staff developer and one password and for the last year and a half or so I've been building suborbital which is a group of open source repos that work together to make web assembly on the server a Useful and practical tool. I'm going to be talking about building web services for a future based on web assembly And I'm going to be doing a deep dive into Atma, which is one of the suborbital projects So a little bit more about what suborbital does it is a collection of projects It started out as a function as a service system But has since evolved to include multiple projects that are all working together towards this goal of server side of web assembly So the projects are reactor. It's a job scheduler It's kind of the core that actually runs the web assembly modules. It manages their memory inputs outputs And all the asynchronous execution that needs to happen grav is a message bus that allows go applications to communicate asynchronously using plugins for discovering each other and also Actually communicating with each other over various protocols and then vector is an HTTP framework that integrates really tightly with grav and reactor And when you put those three together It forms at now and that is what I call the batteries included web assembly framework and includes all the API's and The server side runtime that allows you to build cloud native applications with web assembly and Atmos being developed alongside what I call the Sufa design pattern This is a way of building applications that they're easy to understand and easy to deploy so Sufa stands for simple unified function-based applications and It quite simply means that your application should be simple to understand and simple to deploy using something like a simple autoscaling group It should be unified meaning that when you build them it results in a single thing that thing can be a Docker image or it can be an atmo application bundle But you don't need to build many Docker images or many different things in order for your system to work properly and then function-based means that you are segmenting your application into multiple different functions that are composed together to form your business logic and we'll talk about how that works using the directive which is a declarative file that describes your application and actually lets you compose those functions together using different control flows and Different clauses and operators that make it really easy to work with complex logic We'll talk about a whole lot more of that in a minute So we're gonna go deep into atmo I'm gonna give you a quick tour of an atmo application and we'll talk about how it all works The application that I'm gonna go through is called telescope. It is on my github My github is co-hix COHIX. You can find all the source code there and you can try it out for yourself so the directive is where everything starts and So I'll take you through a quick tour of it It describes all the endpoints that this application will provide things like getting files getting a list of repos getting a single repo and Generating report and we'll talk about this one a little bit more later But the overall goal of the application is to provide information about the repos in our organization So let's dive in and look at the list repos runnable So this one's written in Rust atmo supports rust and Swift and more languages are coming soon But what they all have in common is they use something called the suborbital runnable API in order to gain access to capabilities That server-side applications need to operate properly So things like access and cache making HTTP requests and more these are all granted by the host to Work with the web assembly sandbox and sure you have everything you need to build your application without sacrificing the security that web assembly provides so the runnable itself conforms conforms to the runnable trait and That just means it has a run function that takes an input provides either an output or an error and Then it uses that runnable API to actually do something interesting so in this case we're using the file API to get some configuration and This allows you to actually package static files with your application and they get mounted as a read-only file system that you can access from your modules So for example, if I'm getting this organization configuration file that tells me which organization that the application is being run against and I can use things like the HTTP client and access things like a cache now this directive is using the The runnable to respond directly to the request and so the runnable responds with json and actually sets some response headers like the content type So let's take a look at what it actually means to run this application We're going to use the sub-article cli tool which is called subo And we're going to run subo build I'm going to pass the native flag because I want to use the tool chains on my local machine If you don't have the various language tool chains installed subo actually ships with a Docker runtime that can build your applications without needing to have for example the cargo tool chain installed So it builds all of my web assembly modules and it builds a bundle that includes the web assembly Modules my static files and my directive. So it's everything that atmo needs to actually execute my application So if I start up a development server here using subo dev It is going to start atmo and we can take a look at how it works So I'll start by making a request to that repos endpoint to get a list of all of the repos in the sub-wobble organization And take note that it took about 300 milliseconds to respond to that request You know, I was talking to the github api. So there's multiple network cops involved, etc But if you'll remember we were Talking to the cache and we were actually filling that in with repo information So if we go over here and make a request to get a single repo You'll notice that it executes much more quickly because the get repo Runnable is actually accessing the cache And if the repo information is available It is returning that but if it's not it goes Accesses the github api and then fills in the cache behind it So that's an example of some of the different sub orbital runnable api is available But let's look at a slightly more complicated Handler so this report endpoint for example It combines multiple runnables together in order to do something a little bit more fun So we're using the list repos runnable from the other handler But instead of just responding directly with that information This particular handler actually uses the for each operator to iterate over the array of repos And perform an operation on each element So we're actually going to be calling this send report runnable on each element of the repos list And that send report function looks a little bit like this It's going to Get the element that it is being operated upon It's going to filter out the repos that have less than five stars It is going to Read a configuration file called webhook to know where it wants to send this report to And it's going to construct a payload and then actually send a webhook using the htdp client So why don't we take a look at that? If we send that api v1 report request You'll see something happening in the background here And we're actually getting some messages in discord And we're getting a report about the various repos and the number of stargazers that they have as long as they have more than five So this is you know a couple of different examples about how you can compose web assembly modules together to form logic And I hope it's a good example of how web assembly can be useful on the server now there is A bunch of Additional apis that I didn't talk about here And there are a number of other control flow clauses that you can use in the directive So I suggest you look at atmo dot sub orbital dev to see the entire documentation and what is possible The subo cli also has a number of other features as well that I suggest you check out It's very useful for building web assembly applications whether they're being used for atmo or not So that's the end of the demo and I just want to close out by saying thank you for having me at the conference And I hope you'll check out sub orbital at github.com slash sub orbital And please don't hesitate to open issues or join our discord if you have any questions Or if you want to ask about building something with one of the projects So that's all for me and I will see you all in the conference