diff --git a/tutorials_tutorials/curl-as-a-service.md b/tutorials_tutorials/curl-as-a-service.md index 2042557..d1713b0 100644 --- a/tutorials_tutorials/curl-as-a-service.md +++ b/tutorials_tutorials/curl-as-a-service.md @@ -6,27 +6,27 @@ ### Adapter Construction -The work for the cUrl adapter has been fundamentally done and is exposed by the Fluence Rust SDK. As a developer, the task remaining is to instantiate the adapter in the context of the module and services scope. The following code [snippet](https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/curl_adapter) illustrates the implementation requirement. +The work for the cUrl adapter has been fundamentally done and is exposed by the Fluence Rust SDK. As a developer, the task remaining is to instantiate the adapter in the context of the module and services scope. The following code [snippet](https://github.com/fluencelabs/marine/tree/master/examples/url-downloader/curl_adapter) illustrates the implementation requirement. It is a part of a larger service, [url-downloader](https://github.com/fluencelabs/marine/tree/master/examples/url-downloader). ```rust -use fluence::fce; +use marine_rs_sdk::marine; -use fluence::WasmLoggerBuilder; -use fluence::MountedBinaryResult; +use marine_rs_sdk::WasmLoggerBuilder; +use marine_rs_sdk::MountedBinaryResult; pub fn main() { WasmLoggerBuilder::new().build().unwrap(); } -#[fce] +#[marine] pub fn download(url: String) -> String { - log::info!("get called with url {}", url); + log::info!("download called with url {}", url); let result = unsafe { curl(vec![url]) }; String::from_utf8(result.stdout).unwrap() } -#[fce] +#[marine] #[link(wasm_import_module = "host")] extern "C" { fn curl(cmd: Vec) -> MountedBinaryResult; @@ -36,11 +36,11 @@ extern "C" { with the following dependencies necessary in the Cargo.toml: ```rust -fluence = { version = "=0.4.2", features = ["logger"] } +marine-rs-sdk = { version = "=0.6.11", features = ["logger"] } log = "0.4.8" ``` -We are basically linking the [external](https://doc.rust-lang.org/std/keyword.extern.html) cUrl binary and are exposing access to it as a FCE interface called download. +We are basically linking the [external](https://doc.rust-lang.org/std/keyword.extern.html) cUrl binary and are exposing access to it as a `marine` interface called download. ### Code References @@ -58,48 +58,50 @@ modules_dir = "target/wasm32-wasi/release" name = "curl_adapter" logger_enabled = true - [mounted.mounted_binaries] + [module.mounted_binaries] curl = "/usr/bin/curl" ``` -We are specifying the location of the Wsasm file, the import name of the Wasm file, some logging housekeeping, and the mounted binary reference with the command-line call information. +We are specifying the location of the Wasm file, the import name of the Wasm file, some logging housekeeping, and the mounted binary reference with the command-line call information. ### Remote Service Creation ```bash -cargo new curl-service -cd curl-service +cargo new curl_adapter +cd curl_adapter # copy the above rust code into src/main # copy the specified dependencies into Cargo.toml # copy the above service configuration into Config.toml -fce build --release +marine build --release ``` -You should have the Fluence module curl\_adapter.wasm in `target/wasm32-wasi/release` we can test our service with `fce-repl`. +You should have the Fluence module cur-service.wasm in `target/wasm32-wasi/release` . We can test our service with `mrepl`. -### Service `Test` +### Service Testing -Running the REPL, we use the `interface` command to list all available interfaces and the `call` command to run a method. Fr our purposes, we furnish the [https://duckduckgo.com/?q=Fluence+Labs](https://duckduckgo.com/?q=Fluence+Labs) url to give the the curl adapter a workout. +Running the REPL, we use the `interface` command to list all available interfaces and the `call` command to run a method. For our purposes, we furnish the [https://duckduckgo.com/?q=Fluence+Labs](https://duckduckgo.com/?q=Fluence+Labs) url to give the the curl adapter a workout. ```bash -fce-repl Config.toml -Welcome to the FCE REPL (version 0.5.2) -app service was created with service id = 8ad81c3a-8c5c-4730-80d1-c54cd177725d -elapsed time 40.312376ms +mrepl Config.toml +Welcome to the Marine REPL (version 0.9.1) +Minimal supported versions + sdk: 0.6.0 + interface-types: 0.20.0 + +app service was created with service id = ee63d3ae-304a-42bb-9a2d-4a4dc056a68b +elapsed time 76.5175ms 1> interface Loaded modules interface: curl_adapter: - fn download(url: String) -> String + fn download(url: string) -> string 2> call curl_adapter download ["https://duckduckgo.com/?q=Fluence+Labs"] -result: String("Fluence Labs at DuckDuckGo -ript\">DDG.index = DDG.index || {}; DDG.index.signalSummary = \"\";") - elapsed time: 334.545388ms +result: String("Fluence Labs at DuckDuckGo
") + elapsed time: 356.953459ms -3> +3> ```