Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(marine-book): update to marine-rs-sdk 0.14.0/marine-rs-sdk-test 0.16.1 #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ValeryAntopol
Copy link
Contributor

No description provided.

Copy link

vercel bot commented Mar 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fluence-dev-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 9, 2024 7:10pm

extern "C" {
fn curl(cmd: Vec<String>) -> MountedBinaryResult;
}
```

Note that to import functions from a host, not from other Wasm modules, `wasm_import_module` must be equal to `"host"`.
Note that to import functions from a host, not from other Wasm modules, the `extern` block must be marked by `#[host_import]` macro.

The code above creates a "curl adapter", i.e., a Wasm module that allows other Wasm modules to use the the `curl_request` function, which calls the imported _curl_ binary in this case, to make http calls. Please note that we are wrapping the `extern` block with the `#[marine]` macro and introduce a Marine-native data structure `MountedBinaryResult` as the linked-function return value.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here and throughout, i think we just just stick with effector, e.g., curl_effector or curl effecotr, to match with the Glossary and Glossary link-backs.

Suggested change
The code above creates a "curl adapter", i.e., a Wasm module that allows other Wasm modules to use the the `curl_request` function, which calls the imported _curl_ binary in this case, to make http calls. Please note that we are wrapping the `extern` block with the `#[marine]` macro and introduce a Marine-native data structure `MountedBinaryResult` as the linked-function return value.
The code above creates a "curl effector", i.e., a Wasm module that allows other Wasm modules to use the the `curl_request` function, which calls the imported _curl_ binary in this case, to make http calls. Please note that we are wrapping the `extern` block with the `#[marine]` macro and introduce a Marine-native data structure `MountedBinaryResult` as the linked-function return value.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, the new curl module doesn't use curl_requestany longer. it's nowcurl_getandcurl_post`.


/// Id of the current service.
pub service_id: String,

/// Id of the service creator.
pub service_creator_peer_id: String,

/// Id of the host which run this service.
/// PeerId of the peer who hosts worker with this service.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somewhere along the way, marine book needs to reference/define the term worker, e.g., fluencelabs/dev-rewards#46

@@ -5,7 +5,7 @@ import TabItem from "@theme/TabItem";

The `#[marine]` macro can also wrap a Rust [extern block](https://doc.rust-lang.org/std/keyword.extern.html). In this case, all functions declared in it are considered imported functions. If there are imported functions in some module, say, module A, then

* There should be another module, module B, that exports the same functions. The name of module B is indicated in the `link` macro (see examples below)
* There should be another module, module B, that exports the same functions. The name of module B is indicated in the `module_import` macro (see examples below)
* Module B should be loaded into `Marine` by the moment the loading of module A starts. Module A cannot be loaded if at least one imported function is absent in `Marine`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Module B should be loaded into `Marine` by the moment the loading of module A starts. Module A cannot be loaded if at least one imported function is absent in `Marine`.
* Module B should be loaded into `Marine` when the loading of module A starts. Module A cannot be loaded if one or more imported functions are missing.

extern "C" {
fn curl(cmd: Vec<String>) -> MountedBinaryResult;
}
```

Note that to import functions from a host, not from other Wasm modules, `wasm_import_module` must be equal to `"host"`.
Note that to import functions from a host, not from other Wasm modules, the `extern` block must be marked by `#[host_import]` macro.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Note that to import functions from a host, not from other Wasm modules, the `extern` block must be marked by `#[host_import]` macro.
Note that to import functions from a host, as opposed to imports from other Wasm modules, the `extern` block must be marked by `#[host_import]` macro.

@@ -337,7 +337,7 @@ pub fn what_o_clock(timezone: String) -> SimpleResult {
// here we provide the linking info for the curl-adapter module and expose the
// curl_request method to the facade module
#[marine]
#[link(wasm_import_module = "curl_adapter")]
#[module_import("curl_adapter")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll update the rest. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants