mirror of
https://github.com/fluencelabs/aqua-playground
synced 2025-04-25 18:32:35 +00:00
add and update examples
This commit is contained in:
parent
e1ad9917cb
commit
0bf0ba6d94
14
aqua/dht/dht-example.aqua
Normal file
14
aqua/dht/dht-example.aqua
Normal file
@ -0,0 +1,14 @@
|
||||
import "@fluencelabs/aqua-dht/pubsub.aqua"
|
||||
import "@fluencelabs/aqua-dht/dht.aqua"
|
||||
import "@fluencelabs/aqua-lib/builtin.aqua"
|
||||
|
||||
func put_value(initial_peer: string, value: string) -> string:
|
||||
initTopicAndSubscribe(initial_peer, "some-const3", value, nil, nil)
|
||||
<- "OK"
|
||||
|
||||
func registerKeyPutValue(node_id: string, key: string, value: string, relay_id: ?string, service_id: ?string) -> []string:
|
||||
nodes <- getNeighbours(key, node_id)
|
||||
for n <- nodes par:
|
||||
on n:
|
||||
t <- Peer.timestamp_sec()
|
||||
<- nodes
|
@ -1,8 +0,0 @@
|
||||
import "@fluencelabs/aqua-dht/pubsub.aqua"
|
||||
|
||||
func put_value(initial_peer: string, value: string) -> string:
|
||||
none_service_id: *string
|
||||
on initial_peer:
|
||||
-- Op.noop()
|
||||
initTopicAndSubscribe(initial_peer, "some-const3", value, nil, nil)
|
||||
<- "OK"
|
10
aqua/examples/passArgs.aqua
Normal file
10
aqua/examples/passArgs.aqua
Normal file
@ -0,0 +1,10 @@
|
||||
service AquaDHT("test-dht"):
|
||||
put_host_value(key: string, value: string, service_id: []string) -> string
|
||||
|
||||
func putHostValue(key: string, value: string, service_id: ?string) -> string:
|
||||
res <- AquaDHT.put_host_value(key, value, service_id)
|
||||
<- res
|
||||
|
||||
func create_client_util(service_id: string) -> string:
|
||||
res <- putHostValue("client-util", service_id, nil)
|
||||
<- res
|
10
aqua/examples/streamArgs.aqua
Normal file
10
aqua/examples/streamArgs.aqua
Normal file
@ -0,0 +1,10 @@
|
||||
service TestService("test-service"):
|
||||
get_records(key: string) -> []string
|
||||
|
||||
func append_records(peer: string, srum: *[]string):
|
||||
srum <- TestService.get_records(peer)
|
||||
|
||||
func retrieve_records(peer: string) -> [][]string:
|
||||
records: *[]string
|
||||
append_records(peer, records)
|
||||
<- records
|
16
aqua/examples/streamResults.aqua
Normal file
16
aqua/examples/streamResults.aqua
Normal file
@ -0,0 +1,16 @@
|
||||
data DT:
|
||||
field: string
|
||||
|
||||
service DTGetter("get-dt"):
|
||||
get_dt(s: string) -> DT
|
||||
|
||||
func use_name1(name: string) -> string:
|
||||
results <- DTGetter.get_dt(name)
|
||||
<- results.field
|
||||
|
||||
func use_name2(name: string) -> []string:
|
||||
results: *string
|
||||
results <- use_name1(name)
|
||||
results <- use_name1(name)
|
||||
results <- use_name1(name)
|
||||
<- results
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -61,7 +61,7 @@ export async function doSmth(client: FluenceClient, arg: {value:string}, config?
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for doSmth');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -48,7 +48,7 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?:
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for print');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
@ -130,7 +130,7 @@ h.on('callbackSrv', 'c', (args) => {return c(args[0]);});
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for passFunctionAsArg');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -58,7 +58,7 @@ export async function helloWorld(client: FluenceClient, name: string, config?: {
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for helloWorld');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
@ -105,7 +105,7 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?:
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for print');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
@ -159,7 +159,7 @@ export async function testFunc(client: FluenceClient, config?: {ttl?: number}):
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for testFunc');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
@ -189,7 +189,6 @@ export async function doStuff(client: FluenceClient, a: string, b: string, c: bo
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
@ -209,14 +208,11 @@ export async function doStuff(client: FluenceClient, a: string, b: string, c: bo
|
||||
)
|
||||
(par
|
||||
(par
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("some-id" "t") [str] $stream)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(call a ("op" "noop") [])
|
||||
)
|
||||
(call b ("op" "noop") [])
|
||||
)
|
||||
(call %init_peer_id% ("println-service-id" "print") [a])
|
||||
@ -239,11 +235,8 @@ export async function doStuff(client: FluenceClient, a: string, b: string, c: bo
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call a ("op" "noop") [])
|
||||
)
|
||||
(xor
|
||||
(match c true
|
||||
(xor
|
||||
@ -278,17 +271,12 @@ export async function doStuff(client: FluenceClient, a: string, b: string, c: bo
|
||||
(null)
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
)
|
||||
)
|
||||
(call a ("op" "noop") [])
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(call %init_peer_id% ("some-id" "multiline") [a b c] $stream)
|
||||
@ -329,7 +317,7 @@ h.on('getDataSrv', 'str', () => {return str;});
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for doStuff');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -58,7 +58,7 @@ export async function callConstant(client: FluenceClient, config?: {ttl?: number
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for callConstant');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -55,7 +55,7 @@ export async function getAliasedData(client: FluenceClient, config?: {ttl?: numb
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for getAliasedData');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -71,7 +71,7 @@ export async function betterMessage(client: FluenceClient, relay: string, config
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for betterMessage');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -63,7 +63,7 @@ export async function test(client: FluenceClient, node: string, config?: {ttl?:
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for test');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -48,7 +48,7 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?:
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for print');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
@ -100,7 +100,7 @@ export async function iterateAndPrint(client: FluenceClient, strings: string[],
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for iterateAndPrint');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
@ -168,7 +168,7 @@ h.on('callbackSrv', 'c', (args) => {c(args[0]); return {};});
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for iterateAndPrintParallel');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -37,7 +37,7 @@ export async function getTwoResults(client: FluenceClient, relay: string, config
|
||||
(seq
|
||||
(seq
|
||||
(call relay ("op" "string_to_b58") [%init_peer_id%] k)
|
||||
(call relay ("kad" "neighborhood") [k false] nodes)
|
||||
(call relay ("kad" "neighborhood") [k $nil $nil] nodes)
|
||||
)
|
||||
(fold nodes n
|
||||
(par
|
||||
@ -96,7 +96,7 @@ export async function getTwoResults(client: FluenceClient, relay: string, config
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for getTwoResults');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -55,7 +55,7 @@ export async function testFunc(client: FluenceClient, config?: {ttl?: number}):
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for testFunc');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -58,7 +58,7 @@ export async function helloWorld(client: FluenceClient, name: string, config?: {
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for helloWorld');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -48,7 +48,7 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?:
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for print');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
@ -103,7 +103,7 @@ export async function ifElseCall(client: FluenceClient, condition: boolean, conf
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for ifElseCall');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
@ -158,7 +158,7 @@ export async function ifElseNumCall(client: FluenceClient, condition: number, co
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for ifElseNumCall');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -58,7 +58,7 @@ export async function a(client: FluenceClient, b: string, config?: {ttl?: number
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for a');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
@ -115,7 +115,7 @@ export async function d(client: FluenceClient, e: string, config?: {ttl?: number
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for d');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -70,7 +70,7 @@ export async function getPeerExternalAddresses(client: FluenceClient, otherNodeP
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for getPeerExternalAddresses');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
@ -155,7 +155,7 @@ h.on('getDataSrv', 'viaNode', () => {return viaNode;});
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for getDistantAddresses');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -66,7 +66,7 @@ export async function useOptional(client: FluenceClient, opt: string | null, con
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for useOptional');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -70,7 +70,7 @@ h.on('callbackSrv', 'c', (args) => {c(args[0]); return {};});
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for parFunc');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -48,7 +48,7 @@ export async function print(client: FluenceClient, str: string, config?: {ttl?:
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for print');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -69,7 +69,7 @@ export async function checkStreams(client: FluenceClient, ch: string[], config?:
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for checkStreams');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -100,7 +100,7 @@ h.on('getDataSrv', 'friendRelay', () => {return friendRelay;});
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for topologyTest');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -79,7 +79,7 @@ export async function tryCatchTest(client: FluenceClient, node_id: string, confi
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for tryCatchTest');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -73,7 +73,7 @@ export async function tryOtherwiseTest(client: FluenceClient, node_id: string, c
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for tryOtherwiseTest');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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
|
||||
* Aqua version: 0.1.8-SNAPSHOT
|
||||
* Aqua version: 0.1.9-SNAPSHOT
|
||||
*
|
||||
*/
|
||||
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
@ -101,7 +101,7 @@ h.on('getDataSrv', 'viaAr', () => {return viaAr;});
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for viaArr');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
@ -209,7 +209,7 @@ h.on('getDataSrv', 'viaStr', () => {return viaStr;});
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for viaStream');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
@ -313,7 +313,7 @@ h.on('getDataSrv', 'viaOpt', () => {return viaOpt === null ? [] : [viaOpt];});
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for viaOpt');
|
||||
})
|
||||
if(config?.ttl) {
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
|
10
src/examples/passArgsCall.ts
Normal file
10
src/examples/passArgsCall.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import {FluenceClient, registerServiceFunction} from "@fluencelabs/fluence";
|
||||
import {create_client_util} from "../compiled/examples/passArgs";
|
||||
|
||||
export async function passArgsCall(client: FluenceClient) {
|
||||
registerServiceFunction(client, "test-dht", "put_host_value", (args: any[], _) => {
|
||||
return args[0] + args[1]
|
||||
})
|
||||
|
||||
return await create_client_util(client, "sid")
|
||||
}
|
10
src/examples/streamArgsCall.ts
Normal file
10
src/examples/streamArgsCall.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import {FluenceClient, registerServiceFunction} from "@fluencelabs/fluence";
|
||||
import {retrieve_records} from "../compiled/examples/streamArgs";
|
||||
|
||||
export async function streamArgsCall(client: FluenceClient) {
|
||||
registerServiceFunction(client, "test-service", "get_records", (args: any[], _) => {
|
||||
return [args[0], args[0]]
|
||||
})
|
||||
|
||||
return await retrieve_records(client, "peer_id")
|
||||
}
|
12
src/examples/streamResultsCall.ts
Normal file
12
src/examples/streamResultsCall.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import {FluenceClient, registerServiceFunction} from "@fluencelabs/fluence";
|
||||
import {use_name2} from "../compiled/examples/streamResults";
|
||||
|
||||
export async function streamResultsCall(client: FluenceClient) {
|
||||
registerServiceFunction(client, "get-dt", "get_dt", (args: any[], _) => {
|
||||
return {
|
||||
field: args[0]
|
||||
}
|
||||
})
|
||||
|
||||
return await use_name2(client, "new_name")
|
||||
}
|
@ -22,6 +22,9 @@ import {assignmentCall} from "./examples/assignment";
|
||||
import {tryCatchCall} from "./examples/tryCatchCall";
|
||||
import {tryOtherwiseCall} from "./examples/tryOtherwiseCall";
|
||||
import {coCall} from "./examples/coCall";
|
||||
import {passArgsCall} from "./examples/passArgsCall";
|
||||
import {streamArgsCall} from "./examples/streamArgsCall";
|
||||
import {streamResultsCall} from "./examples/streamResultsCall";
|
||||
let deepEqual = require('deep-equal')
|
||||
|
||||
function checkCall(name: string, expected: any, actual: any, callBackOnError: () => void) {
|
||||
@ -120,7 +123,14 @@ const main = async () => {
|
||||
// coCall.aqua
|
||||
let coCallResult = await coCall(client)
|
||||
|
||||
console.log(tryCatchResult[0])
|
||||
// passArgsCall.aqua
|
||||
let passArgsResult = await passArgsCall(client)
|
||||
|
||||
// streamArgs.aqua
|
||||
let streamArgsResult = await streamArgsCall(client)
|
||||
|
||||
// streamResults.aqua
|
||||
let streamResultsResult = await streamResultsCall(client)
|
||||
|
||||
await client.disconnect();
|
||||
|
||||
@ -165,6 +175,12 @@ const main = async () => {
|
||||
|
||||
checkCall("coCall", coCallResult, [ '/ip4/164.90.171.139/tcp/7770', '/ip4/164.90.171.139/tcp/9990/ws' ], cb)
|
||||
|
||||
checkCall("passArgsCall", passArgsResult, "client-utilsid", cb)
|
||||
|
||||
checkCall("streamArgsCall", streamArgsResult, [["peer_id", "peer_id"]], cb)
|
||||
|
||||
checkCall("streamResultsCall", streamResultsResult, ["new_name", "new_name", "new_name"], cb)
|
||||
|
||||
checkCallBy("tryCatchCall", tryCatchResult, (res) => {
|
||||
return (res[0] as string).includes("Error: Service with id 'unex' not found") && res[1] === '/ip4/164.90.171.139/tcp/7770'
|
||||
}, cb)
|
||||
|
Loading…
x
Reference in New Issue
Block a user