mirror of
https://github.com/fluencelabs/dashboard
synced 2024-12-04 23:30:20 +00:00
refactor air scripts
This commit is contained in:
parent
5bac4d8e6f
commit
d8aa521f60
31
src/AirScripts/CallPeers.elm
Normal file
31
src/AirScripts/CallPeers.elm
Normal file
@ -0,0 +1,31 @@
|
||||
module AirScripts.CallPeers exposing (..)
|
||||
|
||||
import Air exposing (Air)
|
||||
import Air exposing (Air, callBI, fold, next, par, relayEvent, seq, set)
|
||||
import Json.Encode exposing (list, string)
|
||||
|
||||
air : String -> String -> (String, String, String) -> List String -> Air
|
||||
air peerId relayId (event, service, fnName) peers =
|
||||
let
|
||||
clientIdSet =
|
||||
set "clientId" <| string peerId
|
||||
|
||||
relayIdSet =
|
||||
set "relayId" <| string relayId
|
||||
|
||||
peersSet =
|
||||
set "peers" <| list string peers
|
||||
|
||||
airScript =
|
||||
seq
|
||||
(callBI "relayId" ( "op", "identity" ) [] Nothing)
|
||||
(fold "peers" "p" <|
|
||||
par
|
||||
(seq
|
||||
(callBI "p" ( service, fnName ) [] (Just "result"))
|
||||
(relayEvent event [ "p", "result" ])
|
||||
)
|
||||
(next "p")
|
||||
)
|
||||
in
|
||||
clientIdSet <| relayIdSet <| peersSet <| airScript
|
@ -1,31 +1,9 @@
|
||||
module Modules.Air exposing (..)
|
||||
|
||||
import Air exposing (Air, callBI, fold, next, par, relayEvent, seq, set)
|
||||
import Json.Encode exposing (list, string)
|
||||
import Air exposing (Air)
|
||||
import AirScripts.CallPeers
|
||||
|
||||
|
||||
air : String -> String -> List String -> Air
|
||||
air peerId relayId peers =
|
||||
let
|
||||
clientIdSet =
|
||||
set "clientId" <| string peerId
|
||||
|
||||
relayIdSet =
|
||||
set "relayId" <| string relayId
|
||||
|
||||
peersSet =
|
||||
set "peers" <| list string peers
|
||||
|
||||
airScript =
|
||||
seq
|
||||
(callBI "relayId" ( "op", "identity" ) [] Nothing)
|
||||
(fold "peers" "p" <|
|
||||
par
|
||||
(seq
|
||||
(callBI "p" ( "dist", "get_modules" ) [] (Just "modules"))
|
||||
(relayEvent "modules_discovered" [ "p", "modules" ])
|
||||
)
|
||||
(next "p")
|
||||
)
|
||||
in
|
||||
clientIdSet <| relayIdSet <| peersSet <| airScript
|
||||
AirScripts.CallPeers.air peerId relayId ("modules_discovered", "dist", "get_modules") peers
|
||||
|
9
src/Nodes/Air.elm
Normal file
9
src/Nodes/Air.elm
Normal file
@ -0,0 +1,9 @@
|
||||
module Nodes.Air exposing (..)
|
||||
|
||||
import Air exposing (Air)
|
||||
import AirScripts.CallPeers
|
||||
|
||||
|
||||
air : String -> String -> List String -> Air
|
||||
air peerId relayId peers =
|
||||
AirScripts.CallPeers.air peerId relayId ("peer_identity", "op", "identify") peers
|
@ -1,31 +1,9 @@
|
||||
module Services.Air exposing (..)
|
||||
|
||||
import Air exposing (Air, callBI, fold, next, par, relayEvent, seq, set)
|
||||
import Json.Encode exposing (list, string)
|
||||
import Air exposing (Air)
|
||||
import AirScripts.CallPeers
|
||||
|
||||
|
||||
air : String -> String -> List String -> Air
|
||||
air peerId relayId peers =
|
||||
let
|
||||
clientIdSet =
|
||||
set "clientId" <| string peerId
|
||||
|
||||
relayIdSet =
|
||||
set "relayId" <| string relayId
|
||||
|
||||
peersSet =
|
||||
set "peers" <| list string peers
|
||||
|
||||
airScript =
|
||||
seq
|
||||
(callBI "relayId" ( "op", "identity" ) [] Nothing)
|
||||
(fold "peers" "p" <|
|
||||
par
|
||||
(seq
|
||||
(callBI "p" ( "srv", "get_interfaces" ) [] (Just "interfaces"))
|
||||
(relayEvent "services_discovered" [ "p", "interfaces" ])
|
||||
)
|
||||
(next "p")
|
||||
)
|
||||
in
|
||||
clientIdSet <| relayIdSet <| peersSet <| airScript
|
||||
AirScripts.CallPeers.air peerId relayId ("services_discovered", "srv", "get_interfaces") peers
|
||||
|
Loading…
Reference in New Issue
Block a user