Skip to content

Commit 6d55797

Browse files
authored
Merge pull request #1545 from macolso/update-label-ux
updating requirements on default label
2 parents 07e993e + 242db01 commit 6d55797

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

content/wasm-functions/using-key-value-store.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ enable_shortcodes = true
66
---
77

88
- [About the Fermyon Wasm Functions Key Value Store](#about-the-fermyon-wasm-functions-key-value-store)
9+
- [Key Value Limitations and Considerations](#key-value-limitations-and-considerations)
910
- [Creating a New Spin Application](#creating-a-new-spin-application)
1011
- [Grant Key Value Store Permission](#grant-key-value-store-permission)
1112
- [Implementing the Spin Application](#implementing-the-spin-application)
1213
- [Testing the Spin Application](#testing-the-spin-application)
1314
- [Deploying to Fermyon Wasm Functions](#deploying-to-fermyon-wasm-functions)
1415
- [Next Steps](#next-steps)
1516

16-
With Spin Key Value Store support in _Fermyon Wasm Functions_, you can persist non-relational data generated by your [Spin](https://spinframework.dev) application across application restarts and updates. _Fermyon Wasm Functions_ will provision and manage the key value store on your behalf, handling the heavy lifting for you. Spin Key Value Stores are isolated to a single application, and components cannot access the store unless explicitly granted permission. This capabilities-based security model ensures that only authorized components can interact with the data. To learn more about the Spin Key Value Store SDK, please visit the [API guide](https://spinframework.dev/v3/kv-store-api-guide).
17+
With Spin key value store support in _Fermyon Wasm Functions_, you can persist non-relational data generated by your [Spin](https://spinframework.dev) application across application restarts and updates. _Fermyon Wasm Functions_ will provision and manage the key value store on your behalf, handling the heavy lifting for you. Spin key value stores are isolated to a single application, and components cannot access the store unless explicitly granted permission. This capabilities-based security model ensures that only authorized components can interact with the data. To learn more about the Spin key value store SDK, please visit the [API guide](https://spinframework.dev/v3/kv-store-api-guide).
1718

18-
As part of this tutorial, we will build a Spin application which leverages the Key Value Store provided by _Fermyon Wasm Functions_ for persistence. Once we have finished implementing the Spin app, we will run it locally using `spin up` for testing purposes, before we deploy it to _Fermyon Wasm Functions_ using the `spin aka deploy` command.
19+
As part of this tutorial, we will build a Spin application which leverages the key value store provided by _Fermyon Wasm Functions_ for persistence. Once we have finished implementing the Spin app, we will run it locally using `spin up` for testing purposes, before we deploy it to _Fermyon Wasm Functions_ using the `spin aka deploy` command.
1920

2021
## About the Fermyon Wasm Functions Key Value Store
2122

@@ -45,7 +46,9 @@ $ npm install
4546

4647
## Grant Key Value Store Permission
4748

48-
To enable a component in Spin to use a key value store, you need to [grant it the necessary permissions in the application's manifest](https://spinframework.dev/kv-store-api-guide#granting-key-value-store-permissions-to-components) (`spin.toml`) by adding a key-value store label. This both grants the component access to the key value store and signals _Fermyon Wasm Functions_ (FWF) to provision one for the application. In this tutorial, we’ll use the label "default", but you can choose any label that works best for you.
49+
To enable a component in Spin to use a key-value store, you need to [grant it the necessary permissions in the application's manifest](https://spinframework.dev/kv-store-api-guide#granting-key-value-store-permissions-to-components) (`spin.toml`). To do this, add the label of the store to the component's `key_value_stores` in `spin.toml`.
50+
51+
In _Fermyon Wasm Functions_, the only label allowed is `"default"` which signals to the platform to automatically provision a key value store for your Spin application.
4952

5053
```toml
5154
[component.hello-key-value-store]
@@ -58,8 +61,8 @@ key_value_stores = [ "default" ]
5861

5962
The `http-js` template generates a simple _Hello World_ example in `src/index.js`. As part of this section, we'll replace the existing code and use the HTTP router, provided by the template, to make our Spin application respond to the following HTTP request patterns:
6063

61-
- `GET /get/:key` for retrieving a value from Key Value Store using the key provided as `:key`
62-
- `POST /set/:key` for storing a value provided as request payload using `:key` in Key Value Store
64+
- `GET /get/:key` for retrieving a value from key value store using the key provided as `:key`
65+
- `POST /set/:key` for storing a value provided as request payload using `:key` in key value store
6366

6467
Let's start by bringing necessary capabilities from the `@fermyon/spin-sdk` package into scope and laying out the routes:
6568

@@ -84,7 +87,7 @@ addEventListener('fetch', async (event) => {
8487
});
8588
```
8689

87-
Incoming `GET` requests at `/get/:key` will be handled by the `handleGetValue` function. As part of the function, we use the Key Value Store APIs provided by the Spin SDK for JavaScript (`import Kv from '@fermyon/spin-sdk'`):
90+
Incoming `GET` requests at `/get/:key` will be handled by the `handleGetValue` function. As part of the function, we use the key value store APIs provided by the Spin SDK for JavaScript (`import Kv from '@fermyon/spin-sdk'`):
8891

8992
```JavaScript
9093
function handleGetValue(key) {
@@ -97,19 +100,19 @@ function handleGetValue(key) {
97100
return new Response(null, { status: 404 });
98101
}
99102

100-
// load JSON data at key from Key Value Store
103+
// load JSON data at key from key value store
101104
let found = store.getJson(key);
102105

103106
// Return an HTTP 200 with corresponding HTTP header and payload
104-
// if something was found at position key in the Key Value Store
107+
// if something was found at position key in the key value store
105108
return new Response(
106109
JSON.stringify(found),
107110
{ status: 200, headers: { "content-type": "application/json" } }
108111
);
109112
}
110113
```
111114

112-
Incoming `POST` requests at `/set/:key` will be handled by the `handleSetValue` function. After the request payload is validated, we use the Key Value Store APIs for persisting the data.
115+
Incoming `POST` requests at `/set/:key` will be handled by the `handleSetValue` function. After the request payload is validated, we use the key value store APIs for persisting the data.
113116

114117
```JavaScript
115118
function handleSetValue(key, requestBody) {
@@ -209,7 +212,7 @@ Move back to the first terminal instance and terminate your Spin application by
209212

210213
## Deploying to Fermyon Wasm Functions
211214

212-
_Fermyon Wasm Functions_ takes care of provisioning a Key Value Store for you. That said, all we have to do is deploying our Spin application using the `spin aka deploy` command:
215+
_Fermyon Wasm Functions_ takes care of provisioning a key value store for you. That said, all we have to do is deploying our Spin application using the `spin aka deploy` command:
213216

214217
<!-- @selectiveCpy -->
215218

0 commit comments

Comments
 (0)