update examples

This commit is contained in:
vms 2020-08-08 13:38:41 +03:00
parent 6c1ec4b9dc
commit 7e1e94ecc3
30 changed files with 50 additions and 310 deletions

154
Cargo.lock generated
View File

@ -15,15 +15,6 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
[[package]]
name = "aho-corasick"
version = "0.7.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "ansi_term" name = "ansi_term"
version = "0.11.0" version = "0.11.0"
@ -357,33 +348,12 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "effector"
version = "0.1.0"
dependencies = [
"fluence",
"test-record",
]
[[package]] [[package]]
name = "either" name = "either"
version = "1.5.3" version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
[[package]]
name = "env_logger"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"termcolor",
]
[[package]] [[package]]
name = "erased-serde" name = "erased-serde"
version = "0.3.12" version = "0.3.12"
@ -672,14 +642,6 @@ version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
[[package]]
name = "greeting"
version = "0.1.0"
dependencies = [
"anyhow",
"fluence-faas",
]
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.8.1" version = "0.8.1"
@ -713,15 +675,6 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35"
[[package]]
name = "humantime"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
dependencies = [
"quick-error",
]
[[package]] [[package]]
name = "id-arena" name = "id-arena"
version = "2.2.1" version = "2.2.1"
@ -762,12 +715,18 @@ dependencies = [
] ]
[[package]] [[package]]
name = "ipfs_node" name = "ipfs-effector"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "fluence",
"env_logger", "log",
"fluence-app-service", ]
[[package]]
name = "ipfs-pure"
version = "0.1.0"
dependencies = [
"fluence",
"log", "log",
] ]
@ -989,14 +948,6 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "pure"
version = "0.1.0"
dependencies = [
"fluence",
"test-record",
]
[[package]] [[package]]
name = "pwasm-utils" name = "pwasm-utils"
version = "0.12.0" version = "0.12.0"
@ -1008,12 +959,6 @@ dependencies = [
"parity-wasm", "parity-wasm",
] ]
[[package]]
name = "quick-error"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.7" version = "1.0.7"
@ -1101,13 +1046,19 @@ dependencies = [
] ]
[[package]] [[package]]
name = "records" name = "record-effector"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "fluence",
"env_logger", "test-record",
"fluence-faas", ]
"log",
[[package]]
name = "record-pure"
version = "0.1.0"
dependencies = [
"fluence",
"test-record",
] ]
[[package]] [[package]]
@ -1127,24 +1078,6 @@ dependencies = [
"rust-argon2", "rust-argon2",
] ]
[[package]]
name = "regex"
version = "1.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
"thread_local",
]
[[package]]
name = "regex-syntax"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
[[package]] [[package]]
name = "rust-argon2" name = "rust-argon2"
version = "0.7.0" version = "0.7.0"
@ -1333,15 +1266,6 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d"
[[package]]
name = "termcolor"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f"
dependencies = [
"winapi-util",
]
[[package]] [[package]]
name = "test-record" name = "test-record"
version = "0.1.0" version = "0.1.0"
@ -1378,15 +1302,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "thread_local"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
dependencies = [
"lazy_static",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.1.43" version = "0.1.43"
@ -1520,28 +1435,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]] [[package]]
name = "wasm_greeting" name = "wasm-greeting"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence", "fluence",
] ]
[[package]]
name = "wasm_ipfs_node"
version = "0.1.0"
dependencies = [
"fluence",
"log",
]
[[package]]
name = "wasm_ipfs_rpc"
version = "0.1.0"
dependencies = [
"fluence",
"log",
]
[[package]] [[package]]
name = "wasmer-clif-backend-fl" name = "wasmer-clif-backend-fl"
version = "0.17.0" version = "0.17.0"
@ -1748,15 +1647,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "winapi-x86_64-pc-windows-gnu" name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"

View File

@ -5,14 +5,11 @@ members = [
"crates/wit-parser", "crates/wit-parser",
"engine", "engine",
"examples/greeting", "examples/greeting",
"examples/greeting/wasm/", "examples/ipfs-node/effector",
"examples/ipfs_node", "examples/ipfs-node/pure",
"examples/ipfs_node/wasm/ipfs_node", "examples/records/effector",
"examples/ipfs_node/wasm/ipfs_rpc", "examples/records/pure",
"examples/records", "examples/records/test-record",
"examples/records/wasm/effector",
"examples/records/wasm/pure",
"examples/records/wasm/test-record",
"fluence-app-service", "fluence-app-service",
"fluence-faas", "fluence-faas",
"tools/cli", "tools/cli",

View File

@ -1,9 +1,12 @@
[package] [package]
name = "greeting" name = "wasm-greeting"
version = "0.1.0" version = "0.1.0"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
edition = "2018" edition = "2018"
[[bin]]
name = "greeting"
path = "src/main.rs"
[dependencies] [dependencies]
fluence-faas = { path = "../../fluence-faas" } fluence = { git = "https://github.com/fluencelabs/rust-sdk" }
anyhow = "1.0.31"

View File

@ -1,6 +1,6 @@
core_modules_dir = "wasm/artifacts/" modules_dir = "artifacts/"
[[core_module]] [[module]]
name = "greeting.wasm" name = "greeting.wasm"
mem_pages_count = 1 mem_pages_count = 1
logger_enabled = false logger_enabled = false

View File

@ -14,27 +14,11 @@
* limitations under the License. * limitations under the License.
*/ */
use fluence_faas::FluenceFaaS; use fluence::fce;
use fluence_faas::IValue;
use std::path::PathBuf; pub fn main() {}
const GREETING_MODULE_CONFIG_PATH: &str = "Config.toml"; #[fce]
pub fn greeting(name: String) -> String {
fn main() -> Result<(), anyhow::Error> { format!("Hi, {}", name)
let mut greeting_node = FluenceFaaS::new(PathBuf::from(GREETING_MODULE_CONFIG_PATH))?;
println!(
"greeting node interface is\n{}",
greeting_node.get_interface()
);
let result = greeting_node.call(
"greeting.wasm",
"greeting",
&[IValue::String("Fluence".to_string()), IValue::I32(1)],
)?;
println!("execution result {:?}", result);
Ok(())
} }

View File

@ -1,12 +0,0 @@
[package]
name = "wasm_greeting"
version = "0.1.0"
authors = ["Fluence Labs"]
edition = "2018"
[[bin]]
name = "greeting"
path = "src/main.rs"
[dependencies]
fluence = { git = "https://github.com/fluencelabs/rust-sdk" }

View File

@ -1,24 +0,0 @@
/*
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use fluence::fce;
pub fn main() {}
#[fce]
pub fn greeting(name: String) -> String {
format!("Hi, {}", name)
}

View File

@ -1,5 +1,4 @@
modules_dir = "wasm/artifacts/wasm_modules" modules_dir = "artifacts/wasm_modules"
service_base_dir = "/Users/tmp"
[[module]] [[module]]
name = "ipfs_node.wasm" name = "ipfs_node.wasm"
@ -13,6 +12,6 @@ service_base_dir = "/Users/tmp"
envs = ["IPFS_ADDR=/dns4/relay02.fluence.dev/tcp/15001", "timeout=1s"] envs = ["IPFS_ADDR=/dns4/relay02.fluence.dev/tcp/15001", "timeout=1s"]
[[module]] [[module]]
name = "ipfs_rpc.wasm" name = "ipfs_pure.wasm"
mem_pages_count = 100 mem_pages_count = 100
logger_enabled = true logger_enabled = true

View File

@ -1,5 +1,5 @@
[package] [package]
name = "wasm_ipfs_node" name = "ipfs-effector"
version = "0.1.0" version = "0.1.0"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
edition = "2018" edition = "2018"

View File

@ -1,11 +1,11 @@
[package] [package]
name = "wasm_ipfs_rpc" name = "ipfs-pure"
version = "0.1.0" version = "0.1.0"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
edition = "2018" edition = "2018"
[[bin]] [[bin]]
name = "ipfs_rpc" name = "ipfs_pure"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]

View File

@ -1,11 +0,0 @@
[package]
name = "ipfs_node"
version = "0.1.0"
authors = ["Fluence Labs"]
edition = "2018"
[dependencies]
fluence-app-service = { path = "../../fluence-app-service" }
anyhow = "1.0.31"
log = "0.4.11"
env_logger = "0.7.1"

View File

@ -1,42 +0,0 @@
/*
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use fluence_app_service::AppService;
use fluence_app_service::IValue;
use std::path::PathBuf;
const IPFS_MODULES_CONFIG_PATH: &str = "Config.toml";
fn main() -> Result<(), anyhow::Error> {
env_logger::init();
let mut ipfs_node = AppService::with_raw_config();
println!("ipfs node interface is\n{}", ipfs_node.get_interface());
let node_address = ipfs_node.call("ipfs_node.wasm", "get_address", &[])?;
println!("ipfs node address is:\n{:?}", node_address);
let result = ipfs_node.call(
"ipfs_rpc.wasm",
"get",
&[IValue::String(
"QmXdC36pX1B1sdHdbri859vMYctQjAhvTmkWyG9xzhShxb".to_string(),
)],
)?;
println!("execution result {:?}", result);
Ok(())
}

View File

@ -1,11 +0,0 @@
[package]
name = "records"
version = "0.1.0"
authors = ["Fluence Labs"]
edition = "2018"
[dependencies]
fluence-faas = { path = "../../fluence-faas" }
anyhow = "1.0.31"
log = "0.4.11"
env_logger = "0.7.1"

View File

@ -1,11 +1,11 @@
core_modules_dir = "wasm/artifacts/wasm_modules" modules_dir = "artifacts/wasm_modules"
[[core_module]] [[module]]
name = "effector.wasm" name = "effector.wasm"
mem_pages_count = 1 mem_pages_count = 1
logger_enabled = true logger_enabled = true
[[core_module]] [[module]]
name = "pure.wasm" name = "pure.wasm"
mem_pages_count = 1 mem_pages_count = 1
logger_enabled = true logger_enabled = true

View File

@ -1,5 +1,5 @@
[package] [package]
name = "effector" name = "record-effector"
version = "0.1.0" version = "0.1.0"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
edition = "2018" edition = "2018"

View File

@ -1,5 +1,5 @@
[package] [package]
name = "pure" name = "record-pure"
version = "0.1.0" version = "0.1.0"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
edition = "2018" edition = "2018"

View File

@ -1,33 +0,0 @@
/*
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use fluence_faas::FluenceFaaS;
use std::path::PathBuf;
const RECORDS_MODULES_CONFIG_PATH: &str = "Config.toml";
fn main() -> Result<(), anyhow::Error> {
env_logger::init();
let mut records_test = FluenceFaaS::new(PathBuf::from(RECORDS_MODULES_CONFIG_PATH))?;
println!("ipfs node interface is\n{}", records_test.get_interface());
let result = records_test.call("pure.wasm", "invoke", &[])?;
println!("execution result {:?}", result);
Ok(())
}