Skip to content

Commit c0532c7

Browse files
committed
It's time for your daily thwarting
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
1 parent 9c4eee6 commit c0532c7

10 files changed

Lines changed: 45 additions & 26 deletions

.build/check-broken-links.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ if ! blc -rv
9090
--exclude 'https://marketplace.visualstudio.com/items?itemName=BytecodeAlliance.starlingmonkey-debugger' \
9191
--exclude 'http://localhost:16686/' \
9292
--exclude 'http://localhost:5050/explore' \
93+
`## Spin 4 bits not yet published` \
94+
--exclude 'https://github.com/spinframework/spin-docs/blob/main/content/v4' \
95+
--exclude 'https://docs.rs/spin-sdk/latest/spin_sdk' \
9396
http://127.0.0.1:3000/v3/javascript-components \
9497
| tee "${report}"
9598
then

content/v4/contributing-docs.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ keywords = "contribute contributing"
88
---
99

1010
- [Technical Documentation Types](#technical-documentation-types)
11-
- [1. Tutorials](#1-tutorials)
12-
- [2. How-To Guides](#2-how-to-guides)
13-
- [3. Reference](#3-reference)
14-
- [4. Explanation](#4-explanation)
11+
- [1. How-To Guides](#1-how-to-guides)
12+
- [2. Reference](#2-reference)
13+
- [3. Explanation](#3-explanation)
1514
- [Technical Documentation Procedure](#technical-documentation-procedure)
1615
- [1. Fork the Repository](#1-fork-the-repository)
1716
- [2. Clone the Fork](#2-clone-the-fork)
@@ -40,21 +39,17 @@ Below are a few pointers designed to help you contribute.
4039

4140
## Technical Documentation Types
4241

43-
The following points will help guide your contribution from a resource-type perspective; essentially we would really appreciate you creating and contributing any of the following 4 resource types.
42+
The following points will help guide your contribution from a resource-type perspective; essentially we would really appreciate you creating and contributing any of the following 3 resource types.
4443

45-
### 1. Tutorials
46-
47-
Tutorials are oriented toward learning. Tutorials are designed to get a user started on something new (that they have not tried before). You can think of a tutorial as a lesson i.e. teaching a Spin user [how to use the Key Value store to persist data](/key-value-store-tutorial.md). The tutorial may contain many logically ordered steps i.e. installing Spin, using Spin templates, configuring a Spin application and so forth. The desired outcome for a tutorial is for the user to have a working deployment or application. Think of it as a lesson in how to bake a cake.
48-
49-
### 2. How-To Guides
44+
### 1. How-To Guides
5045

5146
How-to guides are oriented towards showing a user how to solve a problem, which leads them to be able to achieve their own goal. The how-to guide will follow a series of logical steps. Think of it as providing a recipe for the user's creativity. For example, you can show a user how to [develop a Spin application](/writing-apps.md) without telling them what the application must do; that is up to the user's imagination.
5247

53-
### 3. Reference
48+
### 2. Reference
5449

5550
Reference resources are merely a dry description; describing the feature in its simplest form. An example of a reference resource is the [Spin application manifest reference](./manifest-reference). You will notice that the Manifest Reference page simply lists all of the manifest entries and available options.
5651

57-
### 4. Explanation
52+
### 3. Explanation
5853

5954
An explanation resource is written using a deep-dive approach i.e. providing a deep explanation with the view to impart a deep understanding of a particular concept, feature or product. You may find your contribution is so in-depth that it becomes a long form article like a blog post. If that is the case, consider an addition to the Spin Blog.
6055

@@ -147,7 +142,7 @@ If you want the code in a code block to be copyable with no "smarts" to remove t
147142

148143
**Multi-tab code blocks**
149144

150-
Examples of multi-tab blocks can be seen in the [Spin installer documentation](./install#installing-spin) and [Spin Key/Value documentation](./key-value-store-tutorial#the-spin-toml-file). The above examples demonstrate how tabs can either represent platforms i.e. `Windows`, `Linux` and `macOS` or represent specific programming languages i.e. `Rust`, `JavaScript` and `Golang` etc. Here is a brief example of how to implement multi-tab code blocks when writing technical documentation for this site, using markdown.
145+
Examples of multi-tab blocks can be seen in the [Spin installer documentation](./install#installing-spin). The above examples demonstrate how tabs can either represent platforms i.e. `Windows`, `Linux` and `macOS` or represent specific programming languages i.e. `Rust`, `JavaScript` and `Golang` etc. Here is a brief example of how to implement multi-tab code blocks when writing technical documentation for this site, using markdown.
151146

152147
The first step to implementing multi-tab code blocks is placing the `enable_shortcodes = true` configuration at the start of the `.md` file. Specifically, in the `.md` file's frontmatter.
153148

content/v4/go-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ WASI can be used when implementing a Spin component.
371371
372372
## Storing Data in the Spin Key-Value Store
373373

374-
Spin has a key-value store built in. For information about using it from TinyGo, see [the key-value store tutorial](key-value-store-tutorial).
374+
Spin has a key-value store built in. For information about using it from TinyGo, see [the key-value API guide](kv-store-api-guide).
375375

376376
## Storing Data in SQLite
377377

content/v4/http-trigger.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ The HTTP component interface is defined using a WebAssembly Interface (WIT) file
310310

311311
The HTTP types and interfaces are defined in [https://github.com/spinframework/spin/tree/main/wit/deps/http@0.3.0-rc-2026-03-15](https://github.com/spinframework/spin/tree/main/wit/deps/http@0.3.0-rc-2026-03-15), which tracks [the `wasi-http` specification](https://github.com/WebAssembly/wasi-http).
312312

313-
In particular, the entry point for Spin HTTP components is defined in [the `handler` interface](https://github.com/spinframework/spin/blob/main/wit/deps/http@0.3.0-rc-2026-03-15/handler.wit):
313+
In particular, the entry point for Spin HTTP components is defined in [the `handler` interface](https://github.com/spinframework/spin/blob/main/wit/deps/http@0.3.0-rc-2026-03-15/worlds.wit):
314314

315315
<!-- @nocpy -->
316316

content/v4/javascript-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ allowed_outbound_hosts = ["redis://localhost:6379"]
309309

310310
## Storing Data in the Spin Key-Value Store
311311

312-
Spin has a key-value store built in. For information about using it from TypeScript/JavaScript, see [the key-value store tutorial](key-value-store-tutorial).
312+
Spin has a key-value store built in. For information about using it from TypeScript/JavaScript, see [the key-value API guide](kv-store-api-guide).
313313

314314
## Storing Data in SQLite
315315

content/v4/kv-store-api-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ url = "https://github.com/spinframework/spin-docs/blob/main/content/v4/kv-store-
1010
- [Custom Key Value Stores](#custom-key-value-stores)
1111
- [Granting Key Value Store Permissions to Components](#granting-key-value-store-permissions-to-components)
1212

13-
Spin provides an interface for you to persist data in a key value store managed by Spin. This key value store allows Spin developers to persist non-relational data across application invocations. To learn more about key value store use cases and how to enable your Spin application to use a key value store, check out our [key value tutorial](./key-value-store-tutorial.md).
13+
Spin provides an interface for you to persist data in a key value store managed by Spin. This key value store allows Spin developers to persist non-relational data across application invocations.
1414

1515
{{ details "Why do I need a Spin interface? Why can't I just use my own external store?" "You can absolutely still use your own external store either with the Redis or Postgres APIs, or outbound HTTP. However, if you're interested in quick, non-relational local storage without any infrastructure set-up then Spin's key value store is a great option." }}
1616

content/v4/rdbms-storage.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ The Spin SDK surfaces the Spin MySQL and PostgreSQL interfaces to your language.
3131
| `query` | statement, SQL parameters | database records | Runs the specified statement against the database, returning the query results as a set of rows. |
3232
| `execute` | statement, SQL parameters | integer (not MySQL) | Runs the specified statement against the database, returning the number of rows modified by the statement. (MySQL does not return the modified row count.) |
3333

34+
> The PostgreSQL interface is asynchronous (a blocking one is available for backward compatibility); the MySQL interface is blocking.
35+
3436
The exact detail of calling these operations from your application depends on your language:
3537

3638
{{ tabs "sdk-type" }}
@@ -39,22 +41,20 @@ The exact detail of calling these operations from your application depends on yo
3941

4042
> [**Want to go straight to the reference documentation?** Find it here.](https://docs.rs/spin-sdk/latest/spin_sdk/index.html)
4143
42-
MySQL functions are available in the `spin_sdk::mysql` module, and PostgreSQL functions in the `spin_sdk::pg4` module.
43-
44-
> If you want to be compatible with Spin 3.3 or earlier, or with downstream hosts that have not yet rolled out Spin 3.4 support, you should use the `spin_sdk::pg3` module for PostgreSQL. The module interfaces are identical, but `pg3` does not support all the data types in `pg4`.
44+
MySQL functions are available in the `spin_sdk::mysql` module, and PostgreSQL functions in the `spin_sdk::pg` module.
4545

46-
The function names match the operations above. This example shows MySQL:
46+
The function names match the operations above. This example shows MySQL (blocking):
4747

4848
```rust
49-
// For PostgreSQL, use `spin_sdk::pg` or `spin_sdk::pg3`
5049
use spin_sdk::mysql::{self, Connection, Decode, ParameterValue};
5150

5251
let connection = Connection::open(&address)?;
5352

5453
let params = vec![ParameterValue::Int32(id)];
55-
// For PostgreSQL, use `$1` placeholder syntax
54+
5655
let rowset = connection.query("SELECT id, name FROM pets WHERE id = ?", &params)?;
5756

57+
// MySQL returns the rows as a vector
5858
match rowset.rows.first() {
5959
None => /* no rows matched query */,
6060
Some(row) => {
@@ -63,6 +63,27 @@ match rowset.rows.first() {
6363
}
6464
```
6565

66+
And PostgreSQL (async):
67+
68+
```rust
69+
use spin_sdk::pg::{self, Connection, Decode, ParameterValue};
70+
71+
let connection = Connection::open(&address).await?;
72+
73+
let params = vec![ParameterValue::Int32(id)];
74+
75+
let (columns, rows, result) = connection.query("SELECT id, name FROM pets WHERE id = $1", &params).await?;
76+
77+
// PostgreSQL returns the rows as a stream
78+
while let Some(row) = rows.next().await {
79+
let name = String::decode(&row[1])?;
80+
// ... more processing ...
81+
}
82+
83+
// Check if the row stream ended due to completion or an error
84+
result.await?;
85+
```
86+
6687
**Notes**
6788

6889
* Parameters are instances of the `ParameterValue` enum; you must wrap raw values in this type.

content/v4/rust-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ The future does not resolve until the stream ends, so be sure not to await it un
446446

447447
## Storing Data in the Spin Key-Value Store
448448

449-
Spin has a key-value store built in. For information about using it from Rust, see [the key-value store tutorial](key-value-store-tutorial).
449+
Spin has a key-value store built in. For information about using it from Rust, see [the key-value API guide](kv-store-api-guide).
450450

451451
### Serializing Objects to the Key-Value Store
452452

content/v4/testing-apps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ key_value_stores = ["default"]
230230
...
231231
```
232232

233-
> If you would like to learn more about Key Value storage, see [this tutorial](./key-value-store-tutorial.md).
233+
> If you would like to learn more about Key Value storage, see [the key-value API guide](kv-store-api-guide).
234234
235235
After editing, the whole `my-app/spin.toml` file will look like the following:
236236

content/v4/writing-apps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ By default, Spin components are not allowed to access Spin's storage services.
356356
key_value_stores = [ "default" ]
357357
```
358358

359-
See [Persisting Data with Spin](key-value-store-tutorial) for more information.
359+
See [the key-value API guide](kv-store-api-guide) for more information.
360360

361361
## Example Manifests
362362

0 commit comments

Comments
 (0)