update aqua

This commit is contained in:
boneyard93501 2021-06-16 18:27:49 -05:00
parent 61b1ba3992
commit 6131577ab0
14 changed files with 88 additions and 189 deletions

View File

@ -1,13 +0,0 @@
(xor
(seq
(seq
(seq
(call %init_peer_id% ("getDataSrv" "relay") [] relay)
(call %init_peer_id% ("getDataSrv" "data") [] data)
)
(call %init_peer_id% ("service-id" "echo") [data] res)
)
(call %init_peer_id% ("callbackSrv" "response") [res])
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error%])
)

View File

@ -1,16 +0,0 @@
(xor
(seq
(seq
(seq
(seq
(call %init_peer_id% ("getDataSrv" "relay") [] relay)
(call %init_peer_id% ("getDataSrv" "name") [] name)
)
(call %init_peer_id% ("getDataSrv" "greeter") [] greeter)
)
(call %init_peer_id% ("service-id" "greeting") [name greeter] res)
)
(call %init_peer_id% ("callbackSrv" "response") [res])
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error%])
)

View File

@ -1,64 +0,0 @@
/**
*
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
import { RequestFlowBuilder } from '@fluencelabs/fluence/dist/api.unstable';
export async function echo(client: FluenceClient, data: string[]): Promise<string[]> {
let request;
const promise = new Promise<string[]>((resolve, reject) => {
request = new RequestFlowBuilder()
.disableInjections()
.withRawScript(
`
(xor
(seq
(seq
(seq
(call %init_peer_id% ("getDataSrv" "relay") [] relay)
(call %init_peer_id% ("getDataSrv" "data") [] data)
)
(call %init_peer_id% ("service-id" "echo") [data] res)
)
(call %init_peer_id% ("callbackSrv" "response") [res])
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error%])
)
`,
)
.configHandler((h) => {
h.on('getDataSrv', 'relay', () => {
return client.relayPeerId!;
});
h.on('getRelayService', 'hasReleay', () => {// Not Used
return client.relayPeerId !== undefined;
});
h.on('getDataSrv', 'data', () => {return data;});
h.onEvent('callbackSrv', 'response', (args) => {
const [res] = args;
resolve(res);
});
h.onEvent('errorHandlingSrv', 'error', (args) => {
// assuming error is the single argument
const [err] = args;
reject(err);
});
})
.handleScriptError(reject)
.handleTimeout(() => {
reject('Request timed out for echo');
})
.build();
});
await client.initiateFlow(request);
return promise;
}

View File

@ -1,68 +0,0 @@
/**
*
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
import { RequestFlowBuilder } from '@fluencelabs/fluence/dist/api.unstable';
export async function greeting(client: FluenceClient, name: string, greeter: boolean): Promise<string> {
let request;
const promise = new Promise<string>((resolve, reject) => {
request = new RequestFlowBuilder()
.disableInjections()
.withRawScript(
`
(xor
(seq
(seq
(seq
(seq
(call %init_peer_id% ("getDataSrv" "relay") [] relay)
(call %init_peer_id% ("getDataSrv" "name") [] name)
)
(call %init_peer_id% ("getDataSrv" "greeter") [] greeter)
)
(call %init_peer_id% ("service-id" "greeting") [name greeter] res)
)
(call %init_peer_id% ("callbackSrv" "response") [res])
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error%])
)
`,
)
.configHandler((h) => {
h.on('getDataSrv', 'relay', () => {
return client.relayPeerId!;
});
h.on('getRelayService', 'hasReleay', () => {// Not Used
return client.relayPeerId !== undefined;
});
h.on('getDataSrv', 'name', () => {return name;});
h.on('getDataSrv', 'greeter', () => {return greeter;});
h.onEvent('callbackSrv', 'response', (args) => {
const [res] = args;
resolve(res);
});
h.onEvent('errorHandlingSrv', 'error', (args) => {
// assuming error is the single argument
const [err] = args;
reject(err);
});
})
.handleScriptError(reject)
.handleTimeout(() => {
reject('Request timed out for greeting');
})
.build();
});
await client.initiateFlow(request);
return promise;
}

View File

@ -1,6 +0,0 @@
service Echo("service-id"):
echo: []string -> []string
func echo(data: []string) -> []string:
res <- Echo.echo(data)
<- res

View File

@ -0,0 +1,67 @@
service OpString("op"):
identity(s: string)
data EchoResult:
echo: string
service EchoService:
echo: []string -> []EchoResult
service GreetingService("service-id"):
greeting: string, bool -> string
-- basic echo service: string array, return array of structs
func echo(names: []string, node: string, echo_service: string) -> []EchoResult:
on node:
EchoService echo_service
res <- EchoService.echo(names)
<- res
func greeting(name:string, greet:bool, node:string, greeting_service_id: string) -> string:
on node:
GreetingService greeting_service_id
res <- GreetingService.greeting(name, greet)
<- res
-- call echo service and and sequentailly call greeting service on each name
-- one service, on one node for all processing needs
func echo_greeting_seq(names: []string, greet: bool, node: string, echo_service_id: string,greeting_service_id: string) -> []string:
res: *string
on node:
EchoService echo_service_id
GreetingService greeting_service_id
echo_names <- EchoService.echo(names)
<- echo_names
for result <- echo_names:
res <- GreetingService.greeting(result.echo, greet)
<- res
data NodeServicePair:
node: string
service_id: string
data EchoServiceInput:
node: string
service_id: string
names: []string
-- call echo service
func echo_greeting_par(names: []string, greet: bool, echo_service: EchoServiceInput, greeting_services: []NodeServicePair) -> []string:
res: *string
on echo_service.node:
EchoService echo_service.service_id
echo_results <- EchoService.echo(names)
for result <- echo_results par:
for greeting_service <- greeting_services:
GreetingService greeting_service.service_id
on greeting_service.node:
res <- GreetingService.greeting(result.echo, greet)
-- this is super annoying
OpString.identity(res!2)
<- res

View File

@ -1,7 +0,0 @@
service Greeting("service-id"):
greeting: string, bool -> string
func greeting(name: string, greeter:bool) -> string:
res <- Greeting.greeting(name, greeter)
<- res

View File

@ -1,3 +1,5 @@
{ {
"name": "greeting" "name": "greeting",
"WEBSITE": "",
"INTERFACES": ""
} }

View File

@ -1,4 +1,7 @@
use marine_rs_sdk::marine; use marine_rs_sdk::marine;
use marine_rs_sdk::module_manifest;
module_manifest!();
#[marine] #[marine]
pub struct Echo { pub struct Echo {

View File

@ -12,6 +12,6 @@ name = "greeting"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]
marine-rs-sdk = { version="0.6.2", feature=["log"]} marine-rs-sdk = { version="0.6.10", feature=["log"]}

View File

@ -3,8 +3,8 @@ set -o errexit -o nounset -o pipefail
# This script builds all subprojects and puts all created Wasm modules in one dir # This script builds all subprojects and puts all created Wasm modules in one dir
mkdir -p artifacts mkdir -p artifacts
cargo update cargo update --aggressive
fce build --release marine build --release
rm -f artifacts/*.wasm rm -f artifacts/*.wasm
cp target/wasm32-wasi/release/greeting.wasm artifacts/ cp target/wasm32-wasi/release/greeting.wasm artifacts/

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2020 Fluence Labs Limited * Copyright 2021 Fluence Labs Limited
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -27,9 +27,9 @@ dependencies = [
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.2" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
@ -44,9 +44,9 @@ checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.93" version = "0.2.97"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41" checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
[[package]] [[package]]
name = "log" name = "log"
@ -134,9 +134,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.26" version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"
dependencies = [ dependencies = [
"unicode-xid", "unicode-xid",
] ]
@ -197,9 +197,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.69" version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb" checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -219,9 +219,9 @@ dependencies = [
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.2.1" version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]] [[package]]
name = "uuid" name = "uuid"

View File

@ -25,6 +25,7 @@ pub fn is_owner() -> bool {
} }
#[marine] #[marine]
#[allow(dead_code)]
pub fn am_i_owner() -> bool { pub fn am_i_owner() -> bool {
is_owner() is_owner()
} }