Extend Spin functionality with plugins
mainspin plugin install, the design vision includes supporting features executed by Spin itself, such as custom triggers (e.g., a timer trigger that executes components at specific intervals).repository·main·Indexed 27 days ago
https://github.com/spinframework/spinAn open source framework for building, deploying, and running fast, secure, and composable cloud microservices using WebAssembly and the WebAssembly component model. It includes the spin-cli for application scaffolding, building, and execution, as well as the spin-componentize library for converting Wasm modules into components. Spin provides official SDKs for Rust, JavaScript, Go, and Python, supporting triggers like HTTP and Redis, and APIs for Key Value storage, SQLite, MySQL, PostgreSQL, and Serverless AI.
spin plugin install, the design vision includes supporting features executed by Spin itself, such as custom triggers (e.g., a timer trigger that executes components at specific intervals).The componentize process utilizes specific adapters to transform plain WebAssembly (Wasm) modules into Wasm components that are compatible with WASI Preview 2. Depending on the version of wit-bindgen being used, different adapters are required:
wit-bindgen version 0.5 and above. These are based on the Wasmtime 18.0.1 release.wit-bindgen version 0.2. This adapter includes specific knowledge of Spin APIs to handle the different ABI used by older wit-bindgen modules.The spin-componentize library converts a Spin module into a WebAssembly component.
Note that while the world specification may include both inbound-redis and inbound-http exports, spin-componentize will only export the specific interfaces that the original module actually exported.
test-codegen-macro is a macro designed to automatically produce #[test] annotated functions based on the existing file directory structure. This is primarily used by runtime tests to eliminate the need for developers to manually write a corresponding test function whenever a new runtime test is added.Spin Factors is a redesigned inversion of control system used to organize independent feature sets (formerly loosely-coupled 'host components') into modular 'factors'. This architecture allows for better integration across different Spin embeddings, such as the Spin CLI and SpinKube, by providing standardized lifecycle hooks and managing an acyclic dependency graph between features.
Key lifecycle integration points include:
When building release infrastructure (e.g., in GitHub Actions), you can sign blobs using cosign sign-blob. This method uses OIDC identities to generate short-lived certificates, eliminating the need for manual private key management.
To use this in a CI environment like GitHub Actions, ensure the job has id-token: write permissions. Use the --output-certificate flag to save the certificate and --output-signature to save the signature, which should then be released alongside the artifact.
$ cosign sign-blob \
--output-certificate out/spin-v1.0.0-linux-amd64-keyless.pem \
--output-signature out/spin-v1.0.0-linux-amd64-keyless.sig \
--yes \
spinRun a Spin application directly from an OCI registry using the --oci flag with the spin up command. This will pull the necessary artifacts before serving the application.
$ spin up --oci ghcr.io/<username>/my-spin-application:v1Note: The Spin documentation website is deprecated and primarily serves as a redirect to new documentation. To run the website locally:
spin up from the documentation directory.http://localhost:3000.$ spin upBecause Spin may process WebSocket frames using different instances or nodes in a cluster, you cannot rely on in-memory state (like mutexes) to manage connection or shared state. You must use a persistent store outside of the instance's memory.
Consistency Considerations:
Spin Built-in Stores:
As of the current implementation, Spin's built-in SQLite and key-value stores do not provide explicit consistency guarantees. For applications requiring strict consistency, you should provide your own external store such as PostgreSQL, MySQL, or Redis.
Distribute your Spin application to a compatible OCI registry using spin oci push. You can specify a custom reference and tag, or derive them from your spin.toml file.
Custom Reference/Tag: Provide the full registry path and tag as an argument.
Derived Reference/Tag:
If you omit the argument, Spin derives the reference and tag from the name and version fields in spin.toml. For this to work, the name in spin.toml must contain the fully qualified reference (e.g., myregistry.com/myusername/myapp).
The Spin project uses cargo vet to manage and audit the security of its Rust dependencies. This process allows maintainers to verify that dependencies are safe to use by either performing manual audits or importing trusted audits from organizations like the Bytecode Alliance (for Wasmtime) or Mozilla.
cargo vet to see if any dependencies are unvetted or require new audits due to updates.cargo vet inspect <crate> <version> to be guided through a manual audit of a specific crate version.cargo vet diff <crate> <old-version> <new-version> to review the differences between two versions before certifying.cargo vet certify <crate> <version> to record the audit.cargo vet suggest to identify dependencies that can be moved from the 'exemptions' list to a formal audit status.The spin login and spin deploy commands are implemented as part of the spin cloud plugin. To maintain backwards compatibility, the core Spin CLI aliases the standard spin login and spin deploy commands to their spin cloud counterparts. If the plugin is not installed, Spin will attempt to install it automatically upon the first invocation of these commands.
$ spin deploy
The `cloud` plugin is required. Installing now.
Plugin 'cloud' was installed successfully!
Uploading cloud_start version 0.1.0+XXXXXXXX...
Deploying...
Waiting for application to become ready... ready
Available Routes:
cloud-start: https://cloud-start-xxxxxxxx.fermyon.app/ (wildcard)