Skip to content

Commit cf6a6f5

Browse files
authored
Merge pull request #7 from fastly/bump-sdk-version
Bump Compute SDK version.
2 parents d5bf288 + d0896d2 commit cf6a6f5

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

.github/workflows/test.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ jobs:
44
test:
55
strategy:
66
matrix:
7-
rust-toolchain: [stable]
7+
rust-toolchain: [1.83.0]
88
platform: [ubuntu-latest]
99
runs-on: ${{ matrix.platform }}
1010
environment: test
1111
steps:
1212
- name: Checkout code
1313
uses: actions/checkout@v3
1414
- name: Install Rust
15-
uses: dtolnay/rust-toolchain@stable
16-
with:
17-
toolchain: ${{ matrix.rust-toolchain }}
15+
uses: dtolnay/[email protected]
1816
- name: Add wasm32-wasi Rust target
1917
run: rustup target add wasm32-wasi --toolchain ${{ matrix.rust-toolchain }}
2018
- name: Cache cargo registry

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ publish = false
1010
debug = 1
1111

1212
[dependencies]
13-
fastly = "0.9.0"
13+
fastly = "0.11.0"

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "stable"
2+
channel = "1.83.0"
33
targets = [ "wasm32-wasi" ]

src/main.rs

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use fastly::kv_store::KVStoreError;
12
use fastly::KVStore;
23
use fastly::{Error, Request, Response};
34

@@ -10,20 +11,20 @@ fn main(req: Request) -> Result<Response, Error> {
1011
}
1112

1213
/*
13-
Construct an KVStore instance which is connected to the KV Store named `my-store`
14+
Construct a KVStore instance which is connected to the KV Store named `my-store`
1415
1516
[Documentation for the KVStore open method can be found here](https://docs.rs/fastly/latest/fastly/struct.KVStore.html#method.open)
1617
*/
17-
let mut store = KVStore::open("my-store").map(|store| store.expect("KVStore exists"))?;
18+
let store = KVStore::open("my-store").map(|store| store.expect("KVStore exists"))?;
1819

1920
let path = req.get_path();
2021
if path == "/readme" {
21-
let entry = store.lookup("readme")?;
22-
23-
return match entry {
24-
// Stream the value back to the user-agent.
25-
Some(entry) => Ok(Response::from_body(entry)),
26-
None => Ok(Response::from_body("Not Found").with_status(404)),
22+
return match store.lookup("readme") {
23+
Ok(mut l) => Ok(Response::from_body(l.take_body())),
24+
Err(KVStoreError::ItemNotFound) => {
25+
return Ok(Response::from_body("Not Found").with_status(404))
26+
}
27+
Err(_e) => return Ok(Response::from_body("Lookup Error").with_status(503)),
2728
};
2829
} else {
2930
/*
@@ -44,12 +45,12 @@ fn main(req: Request) -> Result<Response, Error> {
4445
4546
[Documentation for the lookup method can be found here](https://docs.rs/fastly/latest/fastly/struct.KVStore.html#method.lookup)
4647
*/
47-
let entry = store.lookup("hello")?;
48-
49-
return match entry {
50-
// Stream the value back to the user-agent.
51-
Some(entry) => Ok(Response::from_body(entry)),
52-
None => Ok(Response::from_body("Not Found").with_status(404)),
48+
return match store.lookup("hello") {
49+
Ok(mut l) => Ok(Response::from_body(l.take_body())),
50+
Err(KVStoreError::ItemNotFound) => {
51+
return Ok(Response::from_body("Not Found").with_status(404))
52+
}
53+
Err(_e) => return Ok(Response::from_body("Lookup Error").with_status(503)),
5354
};
5455
}
5556
}

0 commit comments

Comments
 (0)