initial version

This commit is contained in:
vms 2020-04-29 00:59:39 +03:00
parent b4ea84b6a4
commit b30a618095
4 changed files with 135 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
/target
.idea
*.wasm
*.wat

91
Cargo.lock generated Normal file
View File

@ -0,0 +1,91 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "fluence"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "380eb8c085cacb02731b4a4cde79bbfa1870bd650a76d8410f4b3ba82092a33d"
dependencies = [
"fluence-sdk-macro",
"fluence-sdk-main",
]
[[package]]
name = "fluence-sdk-macro"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7004f9b47d73070417105d06a158e1a000bbcd2cf1256bf7522c4fcf09e43aa"
dependencies = [
"fluence-sdk-main",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "fluence-sdk-main"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1433533429c752b55b64b99dbec23849104a82a1a46d34125b66fe0b284dedd7"
dependencies = [
"log",
"syn",
]
[[package]]
name = "log"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
dependencies = [
"cfg-if",
]
[[package]]
name = "multi_module_example"
version = "0.1.0"
dependencies = [
"fluence",
"log",
]
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
dependencies = [
"proc-macro2",
]
[[package]]
name = "syn"
version = "0.15.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"

20
Cargo.toml Normal file
View File

@ -0,0 +1,20 @@
[package]
name = "multi_module_example"
version = "0.1.0"
authors = ["Fluence Labs"]
edition = "2018"
[lib]
name = "multi_module_example"
path = "src/lib.rs"
crate-type = ["cdylib"]
[profile.release]
debug = false
lto = true
opt-level = "z"
panic = "abort"
[dependencies]
fluence = {version = "0.1.11", features = ["wasm_logger", "side_module"]}
log = "0.4"

19
src/lib.rs Normal file
View File

@ -0,0 +1,19 @@
use fluence::sdk::*;
fn init() {
logger::WasmLogger::init_with_level(log::Level::Info).unwrap();
}
#[invocation_handler(init_fn = init, side_modules = (sqlite, redis))]
fn run(arg: String) -> Vec<u8> {
let cmd: Vec<_> = arg.split(" ").collect();
if cmd.len() < 2 {
return "incorrect command".as_bytes().to_vec();
}
match cmd[0] {
"redis" => redis::call(cmd[1].as_bytes()),
"sqlite" => sqlite::call(cmd[1].as_bytes()),
_ => "unknown_command".as_bytes().to_vec(),
}
}