July 12, 2023

Announcing Spin v1.4

Melissa Klein Melissa Klein

spin wasm wasi rust

Announcing Spin v1.4

Today, we are happy to announce Spin 1.4 which includes several enhancements to Spin:

  • Built-in SQLite database provides relational storage right out of the box: nothing to install, no connection strings
  • spin doctor detects problems that could cause you headaches when building and running your apps
  • Plugin badger checks for updates for installed plugins and prompts you to upgrade so you know when a new version is available

Let’s have a look at a few of the highlights of the release!

SQLite support in Spin

You now have more options to store your data! In addition to the built in key-value storage and the Postgres and MySQL database interfaces, Spin now provides a built in SQLite database managed by Spin. This feature provides quick, local relational storage without the need to set up your own infrastructure. Thanks to Spin’s SQLite database interface, you can use your preferred language SDK from Spin to run a common set of operations: open, execute, and close.

Let’s take a quick look on how we would use this new feature.

from spin_http import Response
from spin_sqlite import sqlite_open_default

def handle_request(request):
    # Open a connection to the default database
    conn = sqlite_open_default()
    # Execute SQL 
    result = conn.execute("SELECT * FROM todos WHERE id > (?);", [1])
    # Retrieve the results
    rows = result.rows()
    return Response(200,
                    {"content-type": "application/json"},
                    bytes(str(rows), "utf-8"))

For a full explanation on how to use the SQLite interface with your preferred language, see the SQLite Storage API Guide. The example above uses the default SQLite database, but you can do so much more! In the API Guide you will find details on how to create custom SQLite databases and how to create and alter tables from the command line using the spin up --sqlite command.

Spin Doctor

The spin doctor command can detect problems that could prevent your application from building and running properly and can recommend ways to fix them. Common problems detected by spin doctor include invalid manifests, missing Wasm files, and missing tools.

When you run spin doctor, the tool performs a series of checks on your application. If it finds a problem, it prints a description and recommends a fix if one is available. You can choose to accept the fix, fix it manually later, or see more details about the recommended changes.

Here is an example of the output from spin doctor when it detected an invalid manifest version:

$ spin doctor
📟 The Spin Doctor is in.
🩺 Checking spin.toml...

❗ Diagnosis: Manifest 'spin_manifest_version' must be "1", not "11"
🩹 The Spin Doctor can help! Would you like to:
> Set manifest version to "1"
  Do nothing
  See more details about the recommended changes

Have an idea for a new check for spin doctor? Raise an issue and let us know!

Plugin Badger

Plugins are an important part of the Spin ecosystem. JavaScript and Python developers use them to build their Wasm modules, and, as of Spin 1.3, even Fermyon Cloud deployments depend on a plugin. If your plugins get out of date, though, it can be confusing or frustrating. For example, a TypeScript program that checks out fine against the API might fail to compile to Wasm because you’re on an old version of js2wasm. To help you manage this, Spin 1.4 introduces plugin upgrade notifications, affectionately known as the “plugin badger.”

The way this works is that, when you run a plugin and Spin detects that there’s an upgrade available, Spin prints a little note after the plugin completes, gently “badgering” you to upgrade. Here’s an example, in this case while building a Python application using the py2wasm plugin:

$ spin build
Building component pytest with `spin py2wasm app -o app.wasm`
Spin-compatible module built successfully

This plugin can be upgraded. Version 0.2.0 is available,
but may not be backward compatible with your current plugin.
To upgrade, run `spin plugins upgrade py2wasm`.

And don’t worry - Spin understands that it’s annoying to be badgered about something too often, so once it’s told you about an available upgrade, it won’t mention the same upgrade again for a while.

Thank you!

We would like to thank the over 60 contributors to the Spin project and in particular our new contributor @giodamelio. Hope to see you again in the commit history soon!

A special mention goes out to the maintainers of the Bytecode Alliance projects, particularly the Wasmtime project, as well as the developers working on WASI and the WebAssembly component model. Their work is instrumental in supporting Spin.

Stay in Touch

If you are interested in Spin, Fermyon Cloud, or other Fermyon projects, join the chat in the Fermyon Discord server and follow us on Twitter @fermyontech and @spinframework!

If you would like to get involved in the Spin project, join us at our Spin Community Developers Meeting which is held on the fourth Monday of every month at 2100 UTC. Our next one is on July 26.

Announcing Spin 1.4


🔥 Recommended Posts


Quickstart Your Serveless Apps with Spin

Get Started