mirror of
https://github.com/fluencelabs/dashboard
synced 2024-12-04 15:20:21 +00:00
Gather data in a single particle (#26)
This commit is contained in:
parent
566f26363d
commit
fb5fe8d3a3
@ -4,7 +4,7 @@ alias PeerInfoCb: PeerId, Info, []Service, []Blueprint, []Module -> ()
|
||||
alias ServiceInterfaceCb: PeerId, string, Interface -> ()
|
||||
|
||||
func collectServiceInterfaces(peer: PeerId, services: []Service, collectServiceInterface: ServiceInterfaceCb):
|
||||
for srv <- services:
|
||||
for srv <- services par:
|
||||
on peer:
|
||||
iface <- Srv.get_interface(srv.id)
|
||||
collectServiceInterface(peer, srv.id, iface)
|
||||
@ -28,7 +28,8 @@ func findAndAskNeighboursSchema(relayPeerId: PeerId, clientId: PeerId, collectPe
|
||||
for n2 <- neighbors2 par:
|
||||
askAllAndSend(n2, collectPeerInfo, collectServiceInterface)
|
||||
|
||||
func getAll(relayPeerId: PeerId, knownPeers: []PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb):
|
||||
func getAll(knownPeers: []PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb):
|
||||
on HOST_PEER_ID:
|
||||
-- co askAllAndSend(relayPeerId, collectPeerInfo, collectServiceInterface)
|
||||
|
||||
-- in order to temporarily reduce the number of particles sent to client
|
||||
|
@ -60,7 +60,7 @@ config = args[3];
|
||||
(call %init_peer_id% ("getDataSrv" "services") [] services)
|
||||
)
|
||||
(fold services srv
|
||||
(seq
|
||||
(par
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(xor
|
||||
@ -193,8 +193,7 @@ config = args[3];
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(fold services srv
|
||||
(seq
|
||||
(seq
|
||||
(par
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(xor
|
||||
@ -211,22 +210,17 @@ config = args[3];
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(next srv)
|
||||
)
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
|
||||
)
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 5])
|
||||
)
|
||||
)
|
||||
|
||||
`,
|
||||
@ -372,8 +366,7 @@ config = args[4];
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(fold services srv
|
||||
(seq
|
||||
(seq
|
||||
(par
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(xor
|
||||
@ -390,12 +383,13 @@ config = args[4];
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(next srv)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
|
||||
@ -489,25 +483,22 @@ h.on('getDataSrv', 'clientId', () => {return clientId;});
|
||||
|
||||
export function getAll(...args) {
|
||||
let peer;
|
||||
let relayPeerId;
|
||||
let knownPeers;
|
||||
let collectPeerInfo;
|
||||
let collectServiceInterface;
|
||||
let config;
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
relayPeerId = args[1];
|
||||
knownPeers = args[2];
|
||||
collectPeerInfo = args[3];
|
||||
collectServiceInterface = args[4];
|
||||
config = args[5];
|
||||
} else {
|
||||
peer = Fluence.getPeer();
|
||||
relayPeerId = args[0];
|
||||
knownPeers = args[1];
|
||||
collectPeerInfo = args[2];
|
||||
collectServiceInterface = args[3];
|
||||
config = args[4];
|
||||
} else {
|
||||
peer = Fluence.getPeer();
|
||||
knownPeers = args[0];
|
||||
collectPeerInfo = args[1];
|
||||
collectServiceInterface = args[2];
|
||||
config = args[3];
|
||||
}
|
||||
|
||||
let request;
|
||||
@ -517,14 +508,12 @@ config = args[4];
|
||||
.withRawScript(
|
||||
`
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "relayPeerId") [] relayPeerId)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "knownPeers") [] knownPeers)
|
||||
)
|
||||
(xor
|
||||
(fold knownPeers peer
|
||||
(par
|
||||
(seq
|
||||
@ -554,8 +543,7 @@ config = args[4];
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(fold services srv
|
||||
(seq
|
||||
(seq
|
||||
(par
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(xor
|
||||
@ -572,23 +560,23 @@ config = args[4];
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(next srv)
|
||||
)
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
|
||||
)
|
||||
)
|
||||
(next peer)
|
||||
)
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 5])
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 6])
|
||||
)
|
||||
|
||||
`,
|
||||
@ -597,7 +585,6 @@ config = args[4];
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return peer.getStatus().relayPeerId;
|
||||
});
|
||||
h.on('getDataSrv', 'relayPeerId', () => {return relayPeerId;});
|
||||
h.on('getDataSrv', 'knownPeers', () => {return knownPeers;});
|
||||
|
||||
h.use((req, resp, next) => {
|
||||
|
18
src/index.js
18
src/index.js
@ -25,12 +25,12 @@ import { Fluence, KeyPair, setLogLevel } from '@fluencelabs/fluence';
|
||||
import { Elm } from './Main.elm';
|
||||
import * as serviceWorker from './serviceWorker';
|
||||
import { interfaceInfo, peerInfo } from './types';
|
||||
import { askAllAndSend } from './_aqua/app';
|
||||
import { askAllAndSend, getAll } from './_aqua/app';
|
||||
|
||||
const defaultNetworkName = 'krasnodar';
|
||||
const defaultNetworkName = 'testNet + krasnodar';
|
||||
|
||||
const defaultEnv = {
|
||||
relays: [...krasnodar, ...testNet, ...stage],
|
||||
relays: [...testNet, ...krasnodar, ...stage],
|
||||
relayIdx: 2,
|
||||
logLevel: 'error',
|
||||
};
|
||||
@ -162,11 +162,13 @@ function genFlags(peerId, relays, relayIdx) {
|
||||
}
|
||||
|
||||
app.ports.getAll.subscribe(async (data) => {
|
||||
for (let peer of data.knownPeers) {
|
||||
await askAllAndSend(peer, collectPeerInfo, collectServiceInterface, {
|
||||
ttl: 120000,
|
||||
});
|
||||
}
|
||||
// for (let peer of data.knownPeers) {
|
||||
// await askAllAndSend(peer, collectPeerInfo, collectServiceInterface, {
|
||||
// ttl: 120000,
|
||||
// });
|
||||
// }
|
||||
|
||||
await getAll(data.knownPeers, collectPeerInfo, collectServiceInterface, { ttl: 120000 });
|
||||
});
|
||||
})();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user