update site-storage example

This commit is contained in:
vms 2020-11-30 12:14:21 +03:00
parent 1094d8e504
commit b76fadc453
10 changed files with 72 additions and 90 deletions

144
Cargo.lock generated
View File

@ -108,12 +108,6 @@ dependencies = [
"rustc-demangle",
]
[[package]]
name = "base64"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
[[package]]
name = "base64"
version = "0.13.0"
@ -359,7 +353,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils 0.8.0",
"crossbeam-utils",
]
[[package]]
@ -370,18 +364,18 @@ checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-epoch",
"crossbeam-utils 0.8.0",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.0"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f"
checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d"
dependencies = [
"cfg-if 1.0.0",
"const_fn",
"crossbeam-utils 0.8.0",
"crossbeam-utils",
"lazy_static",
"memoffset",
"scopeguard",
@ -389,24 +383,12 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.7.2"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [
"autocfg",
"cfg-if 0.1.10",
"lazy_static",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5"
checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d"
dependencies = [
"autocfg",
"cfg-if 1.0.0",
"const_fn",
"lazy_static",
]
@ -634,6 +616,15 @@ dependencies = [
"failure",
]
[[package]]
name = "facade"
version = "0.1.0"
dependencies = [
"anyhow",
"fluence 0.2.9 (git+https://github.com/fluencelabs/rust-sdk)",
"log",
]
[[package]]
name = "failure"
version = "0.1.8"
@ -742,20 +733,20 @@ dependencies = [
[[package]]
name = "fluence"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1099731bb64286758969fb8dd6f903d1e4a7398d8e63bdec1be6387576f4d8ab"
source = "git+https://github.com/fluencelabs/rust-sdk#fd9672636e8d7a91275e5e0b8b88a34494336e5a"
dependencies = [
"fluence-sdk-macro 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"fluence-sdk-main 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"fluence-sdk-macro 0.2.9 (git+https://github.com/fluencelabs/rust-sdk)",
"fluence-sdk-main 0.2.9 (git+https://github.com/fluencelabs/rust-sdk)",
]
[[package]]
name = "fluence"
version = "0.2.9"
source = "git+https://github.com/fluencelabs/rust-sdk#fd9672636e8d7a91275e5e0b8b88a34494336e5a"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1099731bb64286758969fb8dd6f903d1e4a7398d8e63bdec1be6387576f4d8ab"
dependencies = [
"fluence-sdk-macro 0.2.9 (git+https://github.com/fluencelabs/rust-sdk)",
"fluence-sdk-main 0.2.9 (git+https://github.com/fluencelabs/rust-sdk)",
"fluence-sdk-macro 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"fluence-sdk-main 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -796,6 +787,14 @@ dependencies = [
"wasmer-wasi-fl",
]
[[package]]
name = "fluence-sdk-macro"
version = "0.2.9"
source = "git+https://github.com/fluencelabs/rust-sdk#fd9672636e8d7a91275e5e0b8b88a34494336e5a"
dependencies = [
"fluence-sdk-wit 0.2.9 (git+https://github.com/fluencelabs/rust-sdk)",
]
[[package]]
name = "fluence-sdk-macro"
version = "0.2.9"
@ -806,11 +805,13 @@ dependencies = [
]
[[package]]
name = "fluence-sdk-macro"
name = "fluence-sdk-main"
version = "0.2.9"
source = "git+https://github.com/fluencelabs/rust-sdk#fd9672636e8d7a91275e5e0b8b88a34494336e5a"
dependencies = [
"fluence-sdk-wit 0.2.9 (git+https://github.com/fluencelabs/rust-sdk)",
"fluence-sdk-macro 0.2.9 (git+https://github.com/fluencelabs/rust-sdk)",
"log",
"serde",
]
[[package]]
@ -824,21 +825,10 @@ dependencies = [
"serde",
]
[[package]]
name = "fluence-sdk-main"
version = "0.2.9"
source = "git+https://github.com/fluencelabs/rust-sdk#fd9672636e8d7a91275e5e0b8b88a34494336e5a"
dependencies = [
"fluence-sdk-macro 0.2.9 (git+https://github.com/fluencelabs/rust-sdk)",
"log",
"serde",
]
[[package]]
name = "fluence-sdk-wit"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9c68c4d07e821e1be23b01c278acdae4e825d03c46879f453426ea3160b3e25"
source = "git+https://github.com/fluencelabs/rust-sdk#fd9672636e8d7a91275e5e0b8b88a34494336e5a"
dependencies = [
"proc-macro2",
"quote",
@ -851,7 +841,8 @@ dependencies = [
[[package]]
name = "fluence-sdk-wit"
version = "0.2.9"
source = "git+https://github.com/fluencelabs/rust-sdk#fd9672636e8d7a91275e5e0b8b88a34494336e5a"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9c68c4d07e821e1be23b01c278acdae4e825d03c46879f453426ea3160b3e25"
dependencies = [
"proc-macro2",
"quote",
@ -1391,9 +1382,9 @@ dependencies = [
[[package]]
name = "memoffset"
version = "0.5.6"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa"
checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87"
dependencies = [
"autocfg",
]
@ -1445,9 +1436,9 @@ dependencies = [
[[package]]
name = "miow"
version = "0.2.1"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d"
dependencies = [
"kernel32-sys",
"net2",
@ -1490,9 +1481,9 @@ dependencies = [
[[package]]
name = "net2"
version = "0.2.35"
version = "0.2.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853"
checksum = "d7cf75f38f16cb05ea017784dc6dbfd354f76c223dba37701734c4f5a9337d02"
dependencies = [
"cfg-if 0.1.10",
"libc",
@ -1866,7 +1857,7 @@ checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a"
dependencies = [
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils 0.8.0",
"crossbeam-utils",
"lazy_static",
"num_cpus",
]
@ -1937,7 +1928,7 @@ version = "0.10.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb15d6255c792356a0f578d8a645c677904dc02e862bebe2ecc18e0c01b9a0ce"
dependencies = [
"base64 0.13.0",
"base64",
"bytes",
"encoding_rs",
"futures-core",
@ -1969,14 +1960,14 @@ dependencies = [
[[package]]
name = "rust-argon2"
version = "0.8.2"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19"
checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb"
dependencies = [
"base64 0.12.3",
"base64",
"blake2b_simd",
"constant_time_eq",
"crossbeam-utils 0.7.2",
"crossbeam-utils",
]
[[package]]
@ -1996,9 +1987,9 @@ dependencies = [
[[package]]
name = "rustop"
version = "1.1.0"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccb57833f46c9d679d68f383e81b9a74b82aa8d6f8a9c9aaae7fc29476bc3274"
checksum = "59a6f317aba7842554266d387a51504f084fc460cab6eb59e19d98dc3d18b9ec"
[[package]]
name = "rustyline"
@ -2170,15 +2161,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
[[package]]
name = "site-storage"
version = "0.1.0"
dependencies = [
"anyhow",
"fluence 0.2.9 (git+https://github.com/fluencelabs/rust-sdk)",
"log",
]
[[package]]
name = "skim"
version = "0.7.0"
@ -2218,11 +2200,11 @@ checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85"
[[package]]
name = "socket2"
version = "0.3.16"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fd8b795c389288baa5f355489c65e71fd48a02104600d15c4cfbc561e9e429d"
checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902"
dependencies = [
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"libc",
"redox_syscall",
"winapi 0.3.9",
@ -2254,9 +2236,9 @@ checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd"
[[package]]
name = "syn"
version = "1.0.48"
version = "1.0.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac"
checksum = "8833e20724c24de12bbaba5ad230ea61c3eafb05b881c7c9d3cfe8638b187e68"
dependencies = [
"proc-macro2",
"quote",
@ -2465,13 +2447,13 @@ checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860"
[[package]]
name = "tracing"
version = "0.1.21"
version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27"
checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3"
dependencies = [
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"log",
"pin-project-lite 0.1.11",
"pin-project-lite 0.2.0",
"tracing-core",
]
@ -2573,9 +2555,9 @@ dependencies = [
[[package]]
name = "unicode-segmentation"
version = "1.7.0"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db8716a166f290ff49dabc18b44aa407cb7c6dbe1aa0971b44b8a24b0ca35aae"
checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
[[package]]
name = "unicode-width"

View File

@ -13,8 +13,8 @@ members = [
"examples/records/effector",
"examples/records/pure",
"examples/records/test-record",
"examples/site-storage/site-storage",
"examples/site-storage/curl",
"examples/site-storage/facade",
"examples/site-storage/local_storage",
"examples/sqlite",
"fluence-app-service",

View File

@ -17,5 +17,5 @@ modules_dir = "artifacts/"
curl = "/usr/bin/curl"
[[module]]
name = "site-storage"
name = "facade"
logger_enabled = true

View File

@ -1,7 +1,7 @@
#!/bin/sh
# This script builds all subprojects and puts all created Wasm modules in one dir
cd site-storage
cd facade
cargo update
fce build --release
cd ../curl
@ -15,4 +15,4 @@ cd ..
rm -f artifacts/*
cp ../../target/wasm32-wasi/release/curl.wasm artifacts/
cp ../../target/wasm32-wasi/release/local_storage.wasm artifacts/
cp ../../target/wasm32-wasi/release/site-storage.wasm artifacts/
cp ../../target/wasm32-wasi/release/facade.wasm artifacts/

View File

@ -1,11 +1,11 @@
[package]
name = "site-storage"
name = "facade"
version = "0.1.0"
authors = ["Fluence Labs"]
edition = "2018"
[[bin]]
name = "site-storage"
name = "facade"
path = "src/main.rs"
[dependencies]

View File

@ -19,7 +19,7 @@ use fluence::fce;
use fluence::WasmLogger;
use std::path::PathBuf;
const RPC_TMP_FILEPATH: &str = "/sites/";
const SITES_DIR: &str = "/sites/";
/// Log level can be changed by `RUST_LOG` env as well.
pub fn main() {
@ -34,7 +34,7 @@ pub fn main() {
pub fn put(name: String, file_content: Vec<u8>) -> String {
log::info!("put called with {:?}", file_content);
let rpc_tmp_filepath = format!("{}{}", RPC_TMP_FILEPATH, name);
let rpc_tmp_filepath = format!("{}{}", SITES_DIR, name);
let result = fs::write(PathBuf::from(rpc_tmp_filepath.clone()), file_content);
if let Err(e) = result {
@ -48,7 +48,7 @@ pub fn put(name: String, file_content: Vec<u8>) -> String {
pub fn get(file_name: String) -> Vec<u8> {
log::info!("get called with file name: {}", file_name);
let tmp_filepath = format!("{}{}", RPC_TMP_FILEPATH, file_name);
let tmp_filepath = format!("{}{}", SITES_DIR, file_name);
fs::read(tmp_filepath).unwrap_or_else(|_| b"error while reading file".to_vec())
}