examples/marine-examples/greeting
2022-06-29 16:58:24 +02:00
..
configs reflecting the deployment config changes (#344) 2022-06-28 11:54:32 +02:00
src update tests 2021-09-01 16:24:37 -05:00
.gitignore Reorg (#10) 2021-07-16 02:04:18 -05:00
build.sh Reorg (#10) 2021-07-16 02:04:18 -05:00
Cargo.toml bump test sdk version 2022-03-19 14:38:21 -05:00
Config.toml update max_heap_size 2022-05-18 02:26:26 -05:00
README.md added readme that describes steps for the greetings example experience (#352) 2022-06-29 16:58:24 +02:00

Greeting

Overview

This is a very simple service comprised of a single Wasm module, where the module only has one function, greeting. Fundamentally, this example illustrates how to build a function as a service (FaaS) for peer-to-peer deployment, with the exciting purpose of providing a hello world experience.

Build

To build the example, please run the following command:

./build.sh

After the build is done, you get the module in the artifacts directory:

➜  greeting git:(main) ✗ ls artifacts
greeting.wasm

Run

Test and inspect the example locally using the mrepl tool:

  greeting git:(main) mrepl Config.toml
Welcome to the Marine REPL (version 0.16.1)
Minimal supported versions
  sdk: 0.6.0
  interface-types: 0.20.0

app service was created with service id = 05251276-81fe-4dad-aea1-f35981077ec1
elapsed time 99.394571ms

1> i
Loaded modules interface:

greeting:
  fn greeting(name: string) -> string

2> call greeting greeting ["Mundo"]
result: String("Hi, Mundo")
 elapsed time: 123.176µs

3> q
➜  greeting git:(main)

Alternatively we can use cargo test:

➜  greeting git:(main) cargo +nightly test --release
 
 ....

    Finished release [optimized] target(s) in 10m 35s
     Running unittests src/main.rs (target/release/deps/greeting-35ba77ac6c6613e5)

running 2 tests
test tests::non_empty_string ... ok
test tests::empty_string ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.14s

➜  greeting git:(main)

For more detailed and in depth reading on the example please refer to the Marine Examples Readme