Announcing Spin 2.2

Today, we are happy to announce Spin 2.2, which includes the following enhancements to Spin:

  • Support for the new stable WASI 0.2.0 via Wasmtime 17
  • Support for multiple trigger types in a single Spin application

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

Spin 2.2

Support for the New Stable WASI 0.2.0

With the launch of Spin 2.0, we introduced production support for the Component Model. This is important for our users, as it enables them to construct robust applications from smaller, isolated components that can effectively communicate in a language-agnostic way. Since WASI Preview 2 was still in development, Spin 2.0 was built on a snapshot of the WASI Preview 2 APIs implemented in Wasmtime 14. In Spin 2.1, we moved to the updated snapshot in Wasmtime 15 while still supporting the old APIs from Wasmtime 14. We did this to ensure that applications built on the older APIs could still function effectively and benefit from the updates without requiring significant overhauls.

On January 25th, the WASI Working Group achieved a major milestone. They approved the WASI Preview 2 APIs, designated as version 0.2.0. With the release of WASI 0.2.0, the WebAssembly community now has a stable set of interfaces for building libraries, tools, and applications. Within a few days, Wasmtime 17 was released, providing implementations of the stable APIs.

In this Spin 2.2 release, we have moved to the stable version of the APIs in Wasmtime 17. We continue to support applications written against the previous snapshots for backward compatibility. All the previously supported WASI 0.2.0 snapshots have been implemented in terms of the final release of WASI 0.2.0. This continues our approach started in Spin 2.1 and demonstrates our commitment to providing stable and reliable solutions for our users while also keeping pace with the latest developments.

Support for Multiple Trigger Types in a Spin Application

One ambitious community member carlokok saw a need for multiple triggers in a single Spin application, so they dove in and started working on a prototype and sought feedback from our maintainers. Soon, a PR was born, and after great conversations, we now have experimental support for multiple trigger types in the same Spin application! This feature is still in its early stages of development. However, it’s exciting to see this frequently requested feature begin to take shape. We will continue to work on this feature and once it is stabilized we will add documentation and examples to the Developer website.

Are you feeling adventurous and want to give it a try? In the Spin 2.2 release, the spin add command isn’t aware that multi-trigger applications are allowed, so you’ll need to roll up your sleeves a bit. You can start by creating separate “dummy” applications with the different triggers that you need (using spin new). Then copy the trigger and component declarations into a “combined” application manifest and the code to a suitable subdirectory. Fiddly, we know, but this is a work in progress!

What does this look like in practice? Let’s say your application provides some analytics for a company that sells coffee machines to cafes. Their purchase orders come into the application via a Redis trigger and call the “on-purchase” component. A cron trigger on the “daily-rollup” component runs every day at midnight to gather metrics on the purchases and store them in an SQLite database. Lastly, the application provides a “dashboard” component on an http trigger that allows users to view the sales metrics.

Your final spin manifest file for the application would look something like this:

spin_manifest_version = 2

name = "purchase-reporting"
version = "1.0.0"

address = "redis://"

channel = "purchases"
component = "on-purchase"

source = "on-purchase/target/wasm32-wasi/release/on_purchase.wasm"
allowed_outbound_hosts = ["mysql://"]
command = "cargo build --target wasm32-wasi --release"
workdir = "on-purchase"
watch = ["src/**/*.rs", "Cargo.toml"]

route = "/..."
component = "dashboard"

source = "dashboard/target/wasm32-wasi/release/dashboard.wasm"
allowed_outbound_hosts = ["mysql://"]
sqlite_databases = ["reporting"]
command = "cargo build --target wasm32-wasi --release"
workdir = "dashboard"
watch = ["src/**/*.rs", "Cargo.toml"]

component = "daily-rollup"
cron_expression = "0 0 0 * * *"

source = "daily-rollup/target/wasm32-wasi/release/daily_rollup.wasm"
allowed_outbound_hosts = ["mysql://"]
sqlite_databases = ["reporting"]
command = "cargo build --target wasm32-wasi --release"
workdir = "daily-rollup"
watch = ["src/**/*.rs", "Cargo.toml"]

Again, this is an experimental feature and work is in progress to make it feature complete. Also, any plugin triggers that you may use will need to be updated to support multiple triggers. In the meantime, please try it out and let us know if you run into any issues. Our documentation has a manifest reference section that you might find helpful.

Please feel free to open an issue on GitHub or reach out on our Discord server. We would love to hear about what you are building and help you succeed in your development endeavors.

Thank You!

We would like to thank the over 75 contributors to the Spin project and, in particular, our new contributors @benwis, @Archisman-Mridha, and @carlokok. 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 and 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 want to get involved in the Spin project, join us at our Spin Community Developers Meeting on the fourth Monday of every month at 11 a.m. Eastern US Time (5 p.m. Berlin Time). Our next one is on February 26. You can watch recordings of the previous meetings on our YouTube Channel.

Interested in learning more?

Talk to us