update to fluence cli 0.4.8

This commit is contained in:
boneyard93501 2023-04-24 00:44:33 -05:00
parent cdec8be7ae
commit 668ae06e0b
14 changed files with 128 additions and 85 deletions

View File

@ -5,3 +5,12 @@
**/**.bk
/artifacts
keypair.json
# recommended by Fluence Labs:
.idea
.fluence
**/node_modules
**/target/
.vscode/settings.json
src/ts/src/aqua
src/js/src/aqua

View File

@ -1,18 +1,2 @@
[package]
name = "wasm-greeting"
version = "0.1.0"
authors = ["Fluence Labs"]
description = "The greeting module for the Fluence network"
repository = "https://github.com/fluencelabs/marine/tree/master/examples/greeting"
edition = "2018"
publish = false
[[bin]]
name = "greeting"
path = "src/main.rs"
[dependencies]
marine-rs-sdk = "0.7.1"
[dev-dependencies]
marine-rs-sdk-test = "0.9.1"
[workspace]
members = [ "service/modules/service" ]

View File

@ -1,6 +0,0 @@
modules_dir = "artifacts/"
[[module]]
name = "greeting"
max_heap_size = "10 Kib"
logger_enabled = false

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
# This script builds all subprojects and puts all created Wasm modules in one dir
cargo update --aggressive
marine build --release
mkdir -p artifacts
rm -f artifacts/*.wasm
cp target/wasm32-wasi/release/greeting.wasm artifacts/

View File

@ -1,5 +0,0 @@
{
"name": "greeting",
"mem_pages_count": 1,
"logger_enabled": false
}

View File

@ -1,11 +0,0 @@
{
"greeting": {
"modules": [
{
"name": "greeting",
"path": "./artifacts/greeting.wasm",
"logger_enabled": true
}
]
}
}

View File

@ -0,0 +1,26 @@
# yaml-language-server: $schema=.fluence/schemas/fluence.yaml.json
# Defines Fluence Project, most importantly - what exactly you want to deploy and how. You can use `fluence init` command to generate a template for new Fluence project
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/fluence.md
version: 2
aquaInputPath: src/aqua/main.aqua
workers:
defaultWorker:
services: [ service ]
deals:
defaultWorker:
minWorkers: 1
targetWorkers: 3
hosts:
defaultWorker:
peerIds:
- 12D3KooWDUszU2NeWyUVjCXhGEt1MoZrhvdmaQQwtZUriuGN1jTr
relays: kras
services:
service:
get: service
dependencies:
cargo:
mrepl: "0.21.3"

View File

@ -1,19 +0,0 @@
mkdir -p module-exports/modules/greeting
sh ./build.sh
cd module-exports
cp ../target/wasm32-wasi/release/greeting.wasm modules/greeting/
file="modules/greeting/module.yaml"
cat > $file <<- EOF
version: 0
name: local_storage
loggerEnabled: true
EOF
tar -czvf greeting.tar.gz modules
rm -r modules
cd ../
cargo clean

View File

@ -0,0 +1,14 @@
[package]
name = "service"
version = "0.1.0"
edition = "2018"
[[bin]]
name = "service"
path = "src/main.rs"
[dependencies]
marine-rs-sdk = "0.7.1"
[dev-dependencies]
marine-rs-sdk-test = "0.9.0"

View File

@ -0,0 +1,9 @@
# yaml-language-server: $schema=../../../.fluence/schemas/module.yaml.json
# Defines [Marine Module](https://fluence.dev/docs/build/concepts/#modules). You can use `fluence module new` command to generate a template for new module
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/module.md
version: 0
type: rust
name: service

View File

@ -1,19 +1,4 @@
/*
* Copyright 2021 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#![allow(non_snake_case)]
use marine_rs_sdk::marine;
use marine_rs_sdk::module_manifest;

View File

@ -0,0 +1,11 @@
# yaml-language-server: $schema=../.fluence/schemas/service.yaml.json
# Defines a [Marine service](https://fluence.dev/docs/build/concepts/#services), most importantly the modules that the service consists of. You can use `fluence service new` command to generate a template for new service
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/service.md
version: 0
name: service
modules:
facade:
get: modules/service

View File

@ -0,0 +1,56 @@
aqua Main
import "@fluencelabs/aqua-lib/builtin.aqua"
import "@fluencelabs/registry/subnetwork.aqua"
import Registry, Record from "@fluencelabs/registry/registry-service.aqua"
import "@fluencelabs/spell/spell_service.aqua"
import "workers.aqua"
import "services.aqua"
export greeting, greetings_seq, greetings_par
func getWorkers() -> []Record:
workersInfo <- getWorkersInfo()
dealId = workersInfo.deals.defaultWorker.dealId
workersOp <- resolveSubnetwork(dealId)
<- workersOp!
func greeting(arg: string) -> string:
on HOST_PEER_ID:
workers <- getWorkers()
worker = workers[0]
on worker.metadata.peer_id via worker.metadata.relay_id:
res <- Service.greeting(arg)
<- res
func greetings_seq(arg: string) -> [][]string:
result: *[]string
on HOST_PEER_ID:
workers <- getWorkers()
for worker <- workers:
res: *string
on worker.metadata.peer_id via worker.metadata.relay_id:
res <- Service.greeting(arg)
res <<- worker.metadata.peer_id
res <<- worker.metadata.relay_id!
result <<- res
<- result
func greetings_par(arg: string) -> [][]string:
result: *[]string
on HOST_PEER_ID:
workers <- getWorkers()
for worker <- workers par:
res: *string
on worker.metadata.peer_id via worker.metadata.relay_id:
res <- Service.greeting(arg)
res <<- worker.metadata.peer_id
res <<- worker.metadata.relay_id!
result <<- res
-- par Peer.timeout(100000, "timeout")
join result[workers.length -1]
par Peer.timeout(100000, "timeout")
<- result