add README

This commit is contained in:
vms 2020-04-29 01:25:31 +03:00
parent b30a618095
commit fd63e926b4
2 changed files with 51 additions and 3 deletions

46
README.md Normal file
View File

@ -0,0 +1,46 @@
# Multi module example
This is an example of multi modules feature of the Fluence Compute Engine (FCE). It simply passes commands to Redis or SQlite depends on the first parameter:
```
sqlite <sql> => returns result of execution sql request of SQlite
redis <cmd> => the same for Redis
```
# How to build
To build you need Rust with wasm32-unknown-unknown target installed, then just type:
```bash
cargo build --release --target wasm32-unknown-unknown
```
# How to run
To run this example you need FCE and [Redis](https://github.com/fluencelabs/redis/releases/download/0.8.0_w/redis.wasm) and [SQlite](https://github.com/fluencelabs/sqlite/releases/download/0.4.0_w/sqlite3.wasm) wasm binaries.
Then run fce and at first load sqlite and redis and only then this example:
```bush
$> Welcome to the Frank CLI:
$> >> add redis redis.wasm
$> module successfully registered in Frank
$> >> add sqlite sqlite3.wasm
$> module successfully registered in Frank
$> >> add mm mm.wasm
$> module successfully registered in Frank
```
Finally, you could execute requests inside FCE CLI:
```bush
>> execute redis SET A 1
result: +OK
>> execute redis GET A
result: $1
1
>> execute sqlite CREATE VIRTUAL TABLE users USING FTS5(body)
result: OK
>> execute sqlite INSERT INTO users(body) VALUES('AB'), ('BC'), ('CD'), ('DE')
result: OK
>> execute sqlite SELECT * FROM users WHERE users MATCH 'A* OR B*'
result: AB|BC
```

View File

@ -11,9 +11,11 @@ fn run(arg: String) -> Vec<u8> {
return "incorrect command".as_bytes().to_vec();
}
let arg = cmd[1..].join(" ");
match cmd[0] {
"redis" => redis::call(cmd[1].as_bytes()),
"sqlite" => sqlite::call(cmd[1].as_bytes()),
"redis" => redis::call(arg.as_bytes()),
"sqlite" => sqlite::call(arg.as_bytes()),
_ => "unknown_command".as_bytes().to_vec(),
}
}
}