added description of the deployment and run steps (#353)

* added description of the deployment and run steps

* updated the readme, added a reference to the Marine Book

Co-authored-by: igor <dev@igor.sh>
This commit is contained in:
igor 2022-07-01 16:55:27 +02:00 committed by GitHub
parent 1540e5d168
commit ffcbeafaaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 115 additions and 4 deletions

View File

@ -740,7 +740,7 @@ After that IDEs will provide code completion for `marine_test_env`. In order to
## Deploying Services
In each of the examples we created modules and services configurations and tested and inspected them with the Marine REPL. Feels like we're all dressed up and nowhere to go. In this section we briefly discuss how to deploy our modules and configurations to the network as services using the *Greeting* example.
In each of the examples we created modules and services configurations and tested and inspected them with the Marine REPL. In this section we briefly discuss how to deploy our modules and configurations to the network as services using the *Greeting* example.
Before we begin, you need to have the `aqua` tool installed. See the [Tools documentation](https://doc.fluence.dev/docs/knowledge_tools) for more information.
@ -806,4 +806,8 @@ Your peerId: 12D3KooWBVzSqoQqFycENVhw7W5RY1UHwPCn6U9iHG2mbwuCuLq3
"ec71a1fc-66d7-41f4-bff1-f9c07d361bd4"
```
The (peer id, service id) tuple is going to be useful once you start putting the service to work with, say, [Aqua](https://doc.fluence.dev/aqua-book/) and you should hold on the data for future use. Also, you can look up your service on the [Fluence Dashboard](https://dash.fluence.dev/blueprint/8d210ec2b83e4c661c71820b79f02d99908794e8af8034b465762f61682bc43b). For more detailed information regarding the Fluence solution see the [Fluence documentation](https://doc.fluence.dev) and if you have any questions, comments or suggestions for improvements, please open an Issue or PR.
The (peer id, service id) tuple is going to be useful once you start putting the service to work with, say, [Aqua](https://doc.fluence.dev/aqua-book/) and you should hold on the data for future use. Also, you can look up your service on the [Fluence Dashboard](https://dash.fluence.dev/blueprint/8d210ec2b83e4c661c71820b79f02d99908794e8af8034b465762f61682bc43b).
For more detailed information regarding Marine please refer to the [Marine Book](https://doc.fluence.dev/marine-book/).
For more detailed information regarding the Fluence solution see the [Fluence documentation](https://doc.fluence.dev) and if you have any questions, comments or suggestions for improvements, please open an Issue or PR.

View File

@ -15,12 +15,14 @@ To build the example, please run the following command:
After the build is done, you get the module in the `artifacts` directory:
```
➜ greeting git:(main) ls artifacts
➜ greeting git:(main) ls artifacts
greeting.wasm
```
## Run
### Local
Test and inspect the example locally using the `mrepl` tool:
```
@ -66,4 +68,109 @@ test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
➜ greeting git:(main)
```
For more detailed and in depth reading on the example please refer to the [Marine Examples Readme](../README.md#greeting-example)
### Remote
Let's deploy our service first.
We need a target node to deploy to. For that purpose we can leverage the default fluence network:
```
aqua config default_peers
/dns4/kras-00.fluence.dev/tcp/19990/wss/p2p/12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e
/dns4/kras-00.fluence.dev/tcp/19001/wss/p2p/12D3KooWR4cv1a8tv7pps4HH6wePNaK6gf1Hww5wcCMzeWxyNw51
/dns4/kras-01.fluence.dev/tcp/19001/wss/p2p/12D3KooWKnEqMfYo9zvfHmqTLpLdiHXPe4SVqUWcWHDJdFGrSmcA
/dns4/kras-02.fluence.dev/tcp/19001/wss/p2p/12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf
/dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE
/dns4/kras-04.fluence.dev/tcp/19001/wss/p2p/12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi
/dns4/kras-05.fluence.dev/tcp/19001/wss/p2p/12D3KooWCMr9mU894i8JXAFqpgoFtx6qnV1LFPSfVc3Y34N4h4LS
/dns4/kras-06.fluence.dev/tcp/19001/wss/p2p/12D3KooWDUszU2NeWyUVjCXhGEt1MoZrhvdmaQQwtZUriuGN1jTr
/dns4/kras-07.fluence.dev/tcp/19001/wss/p2p/12D3KooWEFFCZnar1cUJQ3rMWjvPQg6yMV2aXWs2DkJNSRbduBWn
/dns4/kras-08.fluence.dev/tcp/19001/wss/p2p/12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt
/dns4/kras-09.fluence.dev/tcp/19001/wss/p2p/12D3KooWD7CvsYcpF9HE9CCV9aY3SJ317tkXVykjtZnht2EbzDPm
```
We also need to create keys by issuing the command:
```
aqua key create
{
"peerId": "<your-created-peer-id>",
"secretKey": "<your-created-secret-key>",
"publicKey": "<your-created-public-key>"
}
```
Now we have everything ready for our deployment:
```
aqua remote deploy_service \
--addr /dns4/kras-01.fluence.dev/tcp/19001/wss/p2p/12D3KooWKnEqMfYo9zvfHmqTLpLdiHXPe4SVqUWcWHDJdFGrSmcA \
--config-path configs/greeting_deploy_cfg.json \
--sk <your-created-secret-key> \
--service greeting
```
Which results in a success message and more importantly, the unique id for the deployed service:
```
Going to upload a module...
2022.06.29 18:16:36 [INFO] created ipfs client to /ip4/178.128.194.190/tcp/5001
(node:16062) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
2022.06.29 18:16:36 [INFO] connected to ipfs
2022.06.29 18:16:36 [INFO] file uploaded
Now time to make a blueprint...
Blueprint id:
0912aa1509eb298e19ede0b3788db936c13009c3bade796c836843441654e723
And your service id is:
"ed7c0122-8952-42b7-bd8b-56efa3f62fce"
```
Now we need to call our service. Let's generate an initial stub for our code, and `marine` is a great tool for that:
```
marine aqua artifacts/greeting.wasm > remote-run.aqua
cat remote-run.aqua
module Greeting declares *
service Greeting:
greeting(name: string) -> string
```
It's our starting point that we need to extend a bit: define the `hello` function that calls our deployed service and [export](https://doc.fluence.dev/aqua-book/language/header#export) it using an `export`:
```
module Greeting declares *
export hello as my_hello
service Greeting:
greeting(name: string) -> string
func hello(name: string, node: string, sid: string) -> string:
on node:
Greeting sid
res <- Greeting.greeting(name)
<- res
```
Since we've got the code now, let's put it into work:
```
aqua run \
--addr /dns4/kras-00.fluence.dev/tcp/19990/wss/p2p/12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e \
--input remote-run.aqua \
--func 'my_hello("igor", "12D3KooWKnEqMfYo9zvfHmqTLpLdiHXPe4SVqUWcWHDJdFGrSmcA", "ed7c0122-8952-42b7-bd8b-56efa3f62fce")'
"Hi, igor"
```
where
`addr` - is a relay peer;
`input` - our [Aqua code](https://doc.fluence.dev/aqua-book/language) we run;
`func` - a function call with parameters that initiates compute.
For more detailed and in depth reading on the example please refer to the [Marine Examples Readme](../README.md#greeting-example).