<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Radu Matei</title>
    <description>The latest articles on DEV Community by Radu Matei (@matei_radu).</description>
    <link>https://dev.to/matei_radu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F742644%2Fe06bb8b8-5471-464a-a782-e1ca3623b372.jpeg</url>
      <title>DEV Community: Radu Matei</title>
      <link>https://dev.to/matei_radu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/matei_radu"/>
    <language>en</language>
    <item>
      <title>Spin 1.0 — The Developer Tool for Serverless WebAssembly</title>
      <dc:creator>Radu Matei</dc:creator>
      <pubDate>Tue, 28 Mar 2023 12:21:10 +0000</pubDate>
      <link>https://dev.to/matei_radu/spin-10-the-developer-tool-for-serverless-webassembly-2bhk</link>
      <guid>https://dev.to/matei_radu/spin-10-the-developer-tool-for-serverless-webassembly-2bhk</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://www.fermyon.com/blog/introducing-spin-v1"&gt;&lt;em&gt;This article originally appeared on the Fermyon blog&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gGSu3Pt0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kvuwc0aorgsiyh7adw0l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gGSu3Pt0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kvuwc0aorgsiyh7adw0l.png" alt="Spin 1.0" width="880" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are delighted to introduce &lt;a href="https://github.com/fermyon/spin/releases/tag/v1.0.0"&gt;Spin 1.0&lt;/a&gt;, the first stable release of the open source developer tool for building serverless applications with WebAssembly (Wasm)! Since we first &lt;a href="https://www.fermyon.com/blog/introducing-spin"&gt;introduced Spin last year&lt;/a&gt;, we have been hard at work together with the community on building a frictionless developer experience for building and running serverless applications with Wasm.&lt;/p&gt;

&lt;p&gt;For this release, we focused on building support for new programming languages (such as JavaScript, TypeScript, Python, or C#, in addition to Rust and Go), connecting to databases, distributing applications using popular registry services, a built-in key/value store for persisting state, running your applications on Kubernetes, or integrating with HashiCorp Vault for managing runtime configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Serverless and WebAssembly
&lt;/h2&gt;

&lt;p&gt;When serverless made its way into mainstream computing, there was an amazing user story that it promised to deliver: &lt;em&gt;as a developer, I can focus on writing the business logic of my application, not worry about where my application is running, and only execute my code when it is actually needed&lt;/em&gt;.&lt;br&gt;
The increasing popularity of modern serverless computing offerings suggests that developers resonate with this approach.&lt;br&gt;
However, developers still perceive some fundamental limitations when using serverless today, such as vendor lock-in, portability, or &lt;a href="https://mikhail.io/serverless/coldstarts/big3/"&gt;cold starts&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Launched in 2017, &lt;a href="https://webassembly.org"&gt;WebAssembly (Wasm)&lt;/a&gt; is a fast and efficient bytecode format originally designed to run non-JavaScript code in the browser. Its &lt;a href="https://00f.net/2023/01/04/webassembly-benchmark-2023"&gt;near-native speed&lt;/a&gt;, &lt;a href="https://fermyon.github.io/spin-benchmarks/criterion/reports/spin-executor_sleep-1ms/concurrency-1/index.html"&gt;fast startup time&lt;/a&gt;, true portability, and &lt;a href="https://webassembly.org/docs/security"&gt;sandboxed execution&lt;/a&gt;, coupled with &lt;a href="https://www.fermyon.com/wasm-languages/webassembly-language-support"&gt;the abundance of programming languages with emerging support for compiling to Wasm&lt;/a&gt;, make it a compelling packaging and execution format for running code outside the browser.&lt;/p&gt;

&lt;p&gt;We believe today, Wasm has the runtime characteristics that can address the limitations of serverless, and with Spin, we want to build the best developer experience for serverless Wasm.&lt;/p&gt;
&lt;h2&gt;
  
  
  Hello, Spin!
&lt;/h2&gt;

&lt;p&gt;Spin is an open source developer tool and framework that helps the user through creating, building, distributing, and running serverless applications with Wasm. We can use &lt;code&gt;spin new&lt;/code&gt; to create a new application based on starter templates, &lt;code&gt;spin build&lt;/code&gt; to compile our application to Wasm, and &lt;code&gt;spin up&lt;/code&gt; to run the application locally.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5YulDdVq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x93nmov6tr4qv5ws52b6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5YulDdVq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x93nmov6tr4qv5ws52b6.png" alt="Spin steps" width="880" height="145"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below is an example of using the &lt;code&gt;spin&lt;/code&gt; CLI to create a new Spin Python application, then adding a JavaScript component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create a new Spin application based on the Python language template.&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;spin new http-py hello-python
&lt;span class="c"&gt;# Add a new JavaScript component based on the language template.&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;spin add http-js goodbye-javascript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running the &lt;code&gt;spin add&lt;/code&gt; command will generate the proper configuration for our component and add it to the &lt;a href="https://developer.fermyon.com/spin/manifest-reference"&gt;&lt;code&gt;spin.toml&lt;/code&gt; manifest file&lt;/a&gt;. For example, here is the &lt;code&gt;spin.toml&lt;/code&gt; section for our Python component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[[component]]&lt;/span&gt;
&lt;span class="c"&gt;# The ID of the component.&lt;/span&gt;
&lt;span class="py"&gt;id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"hello-python"&lt;/span&gt;
&lt;span class="c"&gt;# The Wasm module to instantiate and execute when receiving a request.&lt;/span&gt;
&lt;span class="py"&gt;source&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"hello-python/app.wasm"&lt;/span&gt;
&lt;span class="nn"&gt;[component.trigger]&lt;/span&gt;
&lt;span class="c"&gt;# The route for this component.&lt;/span&gt;
&lt;span class="py"&gt;route&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"/hello"&lt;/span&gt;
&lt;span class="nn"&gt;[component.build]&lt;/span&gt;
&lt;span class="c"&gt;# The command to execute for this component with `spin build`.&lt;/span&gt;
&lt;span class="py"&gt;command&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"spin py2wasm app -o app.wasm"&lt;/span&gt;
&lt;span class="c"&gt;# The working directory for the component.&lt;/span&gt;
&lt;span class="py"&gt;workdir&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"hello-python"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can now build our application with &lt;code&gt;spin build&lt;/code&gt;, then run it locally with &lt;code&gt;spin up&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Compile all components to Wasm by executing their `build` commands.&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;spin build
Executing the build &lt;span class="nb"&gt;command &lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;component hello-python: spin py2wasm app &lt;span class="nt"&gt;-o&lt;/span&gt; app.wasm
Executing the build &lt;span class="nb"&gt;command &lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;component goodbye-javascript: npm run build

Successfully ran the build &lt;span class="nb"&gt;command &lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;the Spin components.
&lt;span class="c"&gt;# Run the application locally.&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;spin up
Logging component stdio to &lt;span class="s2"&gt;".spin/logs/"&lt;/span&gt;

Serving http://127.0.0.1:3000
Available Routes:
  hello-python: http://127.0.0.1:3000/hello
  goodbye-javascript: http://127.0.0.1:3000/goodbye
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the application is running, we can start testing it by sending requests to its components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Send a request to the Python component.&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;curl localhost:3000/hello
Hello, Python!
&lt;span class="c"&gt;# Send a request to the JavaScript component.&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;curl localhost:3000/goodbye
Goodbye, JavaScript!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When handling a request, Spin will create a new isolated Wasm instance corresponding to the Wasm module for the matching component, execute the handler function, then terminate the instance. Each new request will get a fresh Wasm instance, and we can do this because of the incredibly fast startup time for Wasm instances.&lt;/p&gt;

&lt;p&gt;Let's look at some of the features that come with Spin 1.0!&lt;/p&gt;

&lt;h3&gt;
  
  
  Language Support
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--orqJmTkf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tz1s49yfsux1ci927j93.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--orqJmTkf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tz1s49yfsux1ci927j93.png" alt="Spin languages" width="840" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A Spin application is composed of one or more &lt;em&gt;components&lt;/em&gt; — in the case of web applications, their entry points are handler functions that take an HTTP request as an argument and return a formed HTTP response.  We can write Spin components using any language with a Spin SDK (such as &lt;a href="https://developer.fermyon.com/spin/language-support-overview"&gt;Rust, TypeScript and JavaScript, Python, Go, or C#&lt;/a&gt;), or using &lt;a href="https://developer.fermyon.com/spin/other-languages"&gt;any other language that compiles to WASI&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;First, let's look at the Python component from the previous example, which returned "Hello, Python!" — it is a Python function that takes the HTTP request as an argument, then returns a response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Import the Response object from the Spin SDK.
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;spin_http&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Response&lt;/span&gt;

&lt;span class="c1"&gt;# The handler function that returns the response.
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;handle_request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Return an HTTP response with a status, headers, and body.
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="s"&gt;"content-type"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"text/plain"&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt;
                    &lt;span class="nb"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Hello, Python!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In JavaScript, we can write an application by following a popular pattern for HTTP handlers, using a router:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Handle the /api/hello route.&lt;/span&gt;
&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Hello, Spin! Handling route &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Handle the /api/projects/:id route, and extract the route parameter.&lt;/span&gt;
&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/products/:id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Handling product ID: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The handler functions can perform operations such as &lt;a href="https://developer.fermyon.com/spin/http-outbound"&gt;fetching data from external APIs&lt;/a&gt;, &lt;a href="https://github.com/fermyon/spin-fileserver"&gt;serving files&lt;/a&gt;, connecting to databases (such as &lt;a href="https://developer.fermyon.com/spin/rdbms-storage"&gt;relational databases&lt;/a&gt;, or &lt;a href="https://developer.fermyon.com/spin/redis-outbound"&gt;Redis&lt;/a&gt;), or &lt;a href="https://developer.fermyon.com/spin/kv-store"&gt;persisting state using Spin's built-in key/value storage&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We are continuing the work to improve &lt;a href="https://developer.fermyon.com/spin/language-support-overview"&gt;the Spin language SDKs&lt;/a&gt;, and we are thankful for the community's continued effort to help and improve our language SDKs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Persisting State from Spin Applications
&lt;/h3&gt;

&lt;p&gt;As we have learned in previous sections, Spin will create a new Wasm instance for every request — which makes it best suited for stateless, request/response types of workloads. To address managing state there is a built-in API for &lt;a href="https://developer.fermyon.com/spin/kv-store"&gt;persisting and retrieving non-relational data from a key/value store&lt;/a&gt;, and Spin 1.0 comes with a default, built-in store available to every Spin application with minimal configuration.&lt;/p&gt;

&lt;p&gt;Let's see an example of using this API from a Rust component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// key for the application state&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;DATA_KEY&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"app-data"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// application state&lt;/span&gt;
&lt;span class="nd"&gt;#[derive(Serialize,&lt;/span&gt; &lt;span class="nd"&gt;Deserialize,&lt;/span&gt; &lt;span class="nd"&gt;Default)]&lt;/span&gt;
&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;Data&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cd"&gt;/// A simple Spin HTTP component.&lt;/span&gt;
&lt;span class="nd"&gt;#[http_component]&lt;/span&gt;
&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;hello_kv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Result&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Open the default KV store.&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;kv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;Store&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;open_default&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Check whether the key already exists.&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="n"&gt;kv&lt;/span&gt;&lt;span class="nf"&gt;.exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DATA_KEY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// If it exists, get the value and deserialize it.&lt;/span&gt;
        &lt;span class="k"&gt;true&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nn"&gt;serde_json&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from_slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;kv&lt;/span&gt;&lt;span class="nf"&gt;.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DATA_KEY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="k"&gt;false&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nn"&gt;Data&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="c1"&gt;// Update the key/value pair using the new data and set its new value.&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="py"&gt;.views&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;serde_json&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;to_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;kv&lt;/span&gt;&lt;span class="nf"&gt;.set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DATA_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nn"&gt;serde_json&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;to_vec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Besides the built-in key/value store, Spin applications can also connect to external databases (such as &lt;a href="https://developer.fermyon.com/spin/rdbms-storage"&gt;relational databases&lt;/a&gt;, or &lt;a href="https://developer.fermyon.com/spin/redis-outbound"&gt;Redis&lt;/a&gt;), or connect to the new class of serverless databases that expose their connections over HTTP. Let's see an example of &lt;a href="https://github.com/fermyon/spin-js-sdk/tree/main/examples/typescript/planetscale"&gt;using a PlanetScale database from TypeScript&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Full example at https://github.com/radu-matei/spin-planetscale-f1&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;HandleRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@fermyon/spin-sdk&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Use the official PlanetScale client.&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;connect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@planetscale/database&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;conn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Send the queries to the database.&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;races&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;standings&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;all&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="nx"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;SELECT * FROM results&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nx"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;SELECT * FROM races&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nx"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;SELECT * FROM standings&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;]);&lt;/span&gt;

  &lt;span class="c1"&gt;// Construct the response.&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;races&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;races&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;results&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;standings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;standings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="c1"&gt;// Return the response.&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;content-type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As WASI matures, we are excited about the &lt;a href="https://github.com/bytecodealliance/preview2-prototyping/blob/4adcbb222fe4a66d496e2ccbf77deaed3b94e1e1/wit/deps/sockets/tcp.wit#L40-L55"&gt;upcoming work in WASI Preview 2 that will bring networking support to WASI&lt;/a&gt;, which will enable the use of popular database drivers and ORMs from Wasm and Spin applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Distributing Spin Applications Using Registry Services
&lt;/h3&gt;

&lt;p&gt;Registry services such as &lt;a href="https://ghcr.io"&gt;GitHub Container Registry&lt;/a&gt;, &lt;a href="https://hub.docker.com/"&gt;Docker Hub&lt;/a&gt;, or, &lt;a href="https://aws.amazon.com/ecr/"&gt;AWS ECR&lt;/a&gt; are ubiquitous, and many people are already using them as part of their workflow deploying cloud native applications.&lt;/p&gt;

&lt;p&gt;Spin 1.0 &lt;a href="https://developer.fermyon.com/spin/distributing-apps"&gt;supports distributing applications using such registry services&lt;/a&gt; — we can push an application using the &lt;code&gt;spin registry push&lt;/code&gt; command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;spin registry push ghcr.io/radu-matei/hello-spin:v2
Pushed with digest sha256:6f886e428152a32ada6303e825975e1a9798de86977e532991a352d02c98f62c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After pushing the application, we can run it using the registry reference by running &lt;code&gt;spin up -f &amp;lt;reference&amp;gt;&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;spin up &lt;span class="nt"&gt;-f&lt;/span&gt; ghcr.io/radu-matei/hello-spin:v2
Serving http://0.0.0.0:3000
Available Routes:
  hello-python: http://0.0.0.0:3000/hello
  goodbye-javascript: http://0.0.0.0:3000/goodbye
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Signing and Verifying Applications Using Sigstore
&lt;/h3&gt;

&lt;p&gt;Since we can distribute Spin applications using popular registry services, we can also take advantage of ecosystem tools such as &lt;a href="https://sigstore.dev"&gt;Sigstore&lt;/a&gt; and &lt;a href="https://github.com/sigstore/cosign"&gt;Cosign&lt;/a&gt;, which address the software supply chain issue by signing and verifying applications using Sigstore's new &lt;a href="https://docs.sigstore.dev/cosign/keyless/"&gt;keyless signatures&lt;/a&gt; (using OIDC identity tokens from providers such as GitHub).&lt;/p&gt;

&lt;p&gt;We can sign Spin applications using a GitHub identity, and guarantee the identity of the actor who pushed the application to the registry, as well as the integrity of the content pushed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Sign the application using the GitHub identity signed in your browser.&lt;/span&gt;
&lt;span class="c"&gt;# If running in automation such as GitHub Actions, this can use the OIDC token&lt;/span&gt;
&lt;span class="c"&gt;# GitHub makes available for workflows.&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;cosign sign ghcr.io/radu-matei/hello-spin@sha256:6f886e428152a32ada6303e825975e1a9798de86977e532991a352d02c98f62c
Generating ephemeral keys...
Retrieving signed certificate...

Successfully verified SCT...
tlog entry created with index: 15825036
Pushing signature to: ghcr.io/radu-matei/hello-spin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can verify the integrity of the application by running &lt;code&gt;cosign verify&lt;/code&gt; and passing the expected issuer and identity of who pushed the application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Verify the content of the artifact at the given digest, as well as the fact&lt;/span&gt;
&lt;span class="c"&gt;# that the signature has been created by a GitHub actor with the given email.&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;cosign verify ghcr.io/radu-matei/hello-spin@sha256:6f886e428152a32ada6303e825975e1a9798de86977e532991a352d02c98f62c &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--certificate-oidc-issuer&lt;/span&gt; https://github.com/login/oauth &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--certificate-identity&lt;/span&gt; radu@fermyon.com

Verification &lt;span class="k"&gt;for &lt;/span&gt;ghcr.io/radu-matei/hello-spin@sha256:6f886e428152a32ada6303e825975e1a9798de86977e532991a352d02c98f62c &lt;span class="nt"&gt;--&lt;/span&gt;
The following checks were performed on each of these signatures:
  - The cosign claims were validated
  - Existence of the claims &lt;span class="k"&gt;in &lt;/span&gt;the transparency log was verified offline
  - The code-signing certificate was verified using trusted certificate authority certificates
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After verifying the signature and validating the integrity of the application, we can run the application by digest instead of using its tag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;spin up &lt;span class="nt"&gt;-f&lt;/span&gt; ghcr.io/radu-matei/hello-spin@sha256:6f886e428152a32ada6303e825975e1a9798de86977e532991a352d02c98f62c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can integrate this workflow into the process of distributing and running your Spin applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploying Spin Applications to Fermyon Cloud
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://fermyon.com/cloud"&gt;Fermyon Cloud&lt;/a&gt; is Fermyon's cloud platform for running serverless Wasm. You can deploy your Spin application and have a running application within seconds. All it takes to sign up for a free account is running &lt;code&gt;spin login &amp;amp;&amp;amp; spin deploy&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Log in to your account or sign up for a new one using `spin login`.&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;spin login
Copy your one-time code: xxxx and open the authorization page &lt;span class="k"&gt;in &lt;/span&gt;your browser: 
https://cloud.fermyon.com/device-authorization

Device authorized!

&lt;span class="c"&gt;# Deploy your application to Fermyon Cloud using `spin deploy`.&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;spin deploy
Uploading hello-spin version 0.1.0+r4a828e1a
Deploying...
Waiting &lt;span class="k"&gt;for &lt;/span&gt;application to become ready........... ready
Available Routes:
  hello-python: https://hello-spin-feiccjxm.fermyon.app/hello
  goodbye-javascript: https://hello-spin-feiccjxm.fermyon.app/goodbye
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We &lt;a href="https://www.fermyon.com/blog/introducing-fermyon-cloud"&gt;launched Fermyon Cloud in open beta at the end of last year&lt;/a&gt;, and we are incredibly happy to see the positive response from the community! As the Spin project and the community evolve, we are excited to build the best place to run your serverless applications with Wasm!&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploying Spin Applications to Kubernetes
&lt;/h3&gt;

&lt;p&gt;Besides deploying the application locally and deploying to Fermyon Cloud, you can also deploy your Spin application to Kubernetes using &lt;a href="https://github.com/deislabs/containerd-wasm-shims/blob/main/containerd-shim-spin-v1/quickstart.md"&gt;the new Containerd integration for Spin&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can deploy this on your own cluster (or alternatively, using &lt;a href="https://kwasm.sh/"&gt;KWasm&lt;/a&gt;), or you can use the &lt;a href="https://learn.microsoft.com/en-us/azure/aks/use-wasi-node-pools"&gt;Azure Kubernetes Service&lt;/a&gt;, which can run Spin (and &lt;a href="https://github.com/deislabs/spiderlightning#spiderlightning-or-slight"&gt;slight&lt;/a&gt;) applications.&lt;/p&gt;

&lt;p&gt;To get started, first configure a new runtime class based on the Containerd integration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;node.k8s.io/v1&lt;/span&gt;
&lt;span class="c1"&gt;# Create a new runtime class based on the containerd Wasm integration&lt;/span&gt;
&lt;span class="c1"&gt;# that can run Spin applications.&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;RuntimeClass&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;wasmtime-spin-v1"&lt;/span&gt;
&lt;span class="na"&gt;handler&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;spin"&lt;/span&gt;
&lt;span class="na"&gt;scheduling&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;nodeSelector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;kubernetes.azure.com/wasmtime-spin-v1"&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;true"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, create a deployment that uses the new runtime class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="c1"&gt;# Create a new Kubernetes deployment.&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;wasm-spin&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;wasm-spin&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;wasm-spin&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="c1"&gt;# Specify the runtime class for this deployment.&lt;/span&gt;
      &lt;span class="na"&gt;runtimeClassName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;wasmtime-spin&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hello-spin&lt;/span&gt;
          &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ghcr.io/radu-matei/hello-spin-kubernetes&lt;/span&gt;
          &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To access the application, you will also need to create a Kubernetes service and potentially an ingress. To simplify this operation, we are working on a Spin plugin for Kubernetes that will automatically scaffold and deploy the required Kubernetes objects — check out &lt;a href="https://github.com/chrismatteson/spin-plugin-k8s"&gt;&lt;code&gt;spin k8s&lt;/code&gt;&lt;/a&gt; We are looking forward to the community's feedback on how to improve deploying Spin applications to Kubernetes! If you are interested in this feature, make sure to &lt;a href="https://discord.gg/AAFNfS7NGf"&gt;reach out on Discord&lt;/a&gt; or &lt;a href="https://twitter.com/fermyontech"&gt;on Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Extending Spin With External Triggers and Plugins
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://developer.fermyon.com/spin/managing-plugins"&gt;Spin plugins&lt;/a&gt; are executables that can extend the functionality of Spin without modifying the Spin codebase. In the previous examples, we have used two such plugins, when building Python and JavaScript applications: &lt;code&gt;spin py2wasm&lt;/code&gt; and &lt;code&gt;spin js2wasm&lt;/code&gt;, as well as the &lt;code&gt;spin k8s&lt;/code&gt; plugin.&lt;br&gt;
Anyone can &lt;a href="https://developer.fermyon.com/spin/plugin-authoring"&gt;write a Spin plugin&lt;/a&gt; to build support for new language SDKs (like the Python and JavaScript plugins), or to build new Spin triggers.&lt;/p&gt;

&lt;p&gt;We are particularly excited about upcoming work to build external queue triggers, such as &lt;a href="https://github.com/fermyon/spin-trigger-sqs"&gt;the experimental AWS SQS trigger&lt;/a&gt;. Once stabilized, with the plugin installed, &lt;code&gt;spin up&lt;/code&gt; will be able to start an application that is triggered on new messages with specific attributes on a given queue.&lt;/p&gt;

&lt;h3&gt;
  
  
  Beyond Spin 1.0
&lt;/h3&gt;

&lt;p&gt;The main focus for Spin 1.0 has been stabilizing core parts of the &lt;code&gt;spin new&lt;/code&gt; -&amp;gt; &lt;code&gt;spin build&lt;/code&gt; -&amp;gt; &lt;code&gt;spin up&lt;/code&gt; workflow. As a result, there are several features we are looking forward to adding in upcoming minor versions of Spin, such as more triggers, a &lt;a href="https://github.com/fermyon/spin/pull/1237"&gt;&lt;code&gt;spin watch&lt;/code&gt; command to further improve the inner development loop&lt;/a&gt;, feature parity for language SDKs, and new services for persistence (including in Spin key/value and relational database APIs).&lt;/p&gt;

&lt;p&gt;But perhaps the most exciting is going to be the transition to using &lt;a href="https://github.com/bytecodealliance/preview2-prototyping"&gt;WASI Preview 2&lt;/a&gt; and &lt;a href="https://www.fermyon.com/blog/webassembly-component-model"&gt;the Wasm component model&lt;/a&gt;, which will bring a host of improvements and new features! We are hoping to make significant progress here over the next few months, so stay tuned!&lt;/p&gt;

&lt;p&gt;If you have ideas or requests for features or improvements we can make to Spin, make sure to &lt;a href="https://discord.gg/AAFNfS7NGf"&gt;reach out on Discord&lt;/a&gt; or &lt;a href="https://twitter.com/fermyontech"&gt;on Twitter&lt;/a&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Building on Open Source and With the Community
&lt;/h2&gt;

&lt;p&gt;Spin is built using &lt;a href="https://github.com/bytecodealliance/wasmtime"&gt;Wasmtime&lt;/a&gt;, a popular Wasm runtime built by the &lt;a href="https://bytecodealliance.org/"&gt;Bytecode Alliance&lt;/a&gt;, and the &lt;a href="https://www.fermyon.com/blog/webassembly-component-model"&gt;Wasm component model proposal&lt;/a&gt;, and Spin would not be possible without the amazing effort of the maintainers of those projects.&lt;/p&gt;

&lt;p&gt;We are excited to contribute back to Wasmtime and the component model, as well as to new projects and proposals emerging in this space (such as new Wasm proposals, like &lt;a href="https://github.com/bytecodealliance/preview2-prototyping"&gt;WASI Preview 2&lt;/a&gt;, &lt;a href="https://github.com/WebAssembly/wasi-keyvalue"&gt;&lt;code&gt;wasi-keyvalue&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/WebAssembly/wasi-sql"&gt;&lt;code&gt;wasi-sql&lt;/code&gt;&lt;/a&gt; or &lt;a href="https://github.com/WebAssembly/WASI/issues/520"&gt;&lt;code&gt;wasi-cloud&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Spin would also not be possible without the more than &lt;a href="https://github.com/fermyon/spin/graphs/contributors"&gt;50 contributors&lt;/a&gt; who are dedicating their time to write code and documentation, and without everyone using the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give It a Spin!
&lt;/h2&gt;

&lt;p&gt;We hope this post got you excited about the possibilities of the Spin project! &lt;a href="https://developer.fermyon.com/spin/quickstart"&gt;Head over to the Spin documentation&lt;/a&gt; and build your first Spin application in your favorite programming language today!&lt;/p&gt;

&lt;p&gt;We can't wait to see what you build using Spin 1.0!&lt;/p&gt;

&lt;p&gt;If you are interested in Spin, &lt;a href="https://cloud.fermyon.com"&gt;Fermyon Cloud&lt;/a&gt;, or other Fermyon projects, join the chat in the &lt;a href="https://discord.gg/AAFNfS7NGf"&gt;Fermyon Discord server&lt;/a&gt; and follow us on Twitter &lt;a href="https://twitter.com/fermyontech/"&gt;@fermyontech&lt;/a&gt; and &lt;a href="https://twitter.com/spinframework"&gt;@spinframework&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3B1tzX8I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jqcwune5lrfvaap24baf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3B1tzX8I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jqcwune5lrfvaap24baf.jpg" alt="Spin 1.0" width="880" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>webassembly</category>
      <category>javascript</category>
      <category>python</category>
    </item>
  </channel>
</rss>
