add descriptions, update logs

This commit is contained in:
DieMyst 2020-12-10 17:28:37 +03:00
parent 37432ec0d2
commit e94f3b6f76
5 changed files with 131 additions and 16 deletions

View File

@ -6,6 +6,7 @@ import Dict exposing (Dict)
import Html exposing (Html, a, article, div, img, span, text) import Html exposing (Html, a, article, div, img, span, text)
import Html.Attributes exposing (attribute) import Html.Attributes exposing (attribute)
import Html.Events exposing (onClick) import Html.Events exposing (onClick)
import Info exposing (getBlueprintDescription)
import Instances.View import Instances.View
import Interface.View exposing (interfaceView) import Interface.View exposing (interfaceView)
import Model exposing (Model) import Model exposing (Model)
@ -56,7 +57,7 @@ blueprintToInfo model id =
, id = id , id = id
, author = "Fluence Labs" , author = "Fluence Labs"
, authorPeerId = "fluence_labs_peer_id" , authorPeerId = "fluence_labs_peer_id"
, description = "Excelent blueprint" , description = getBlueprintDescription bp.name
, website = "https://github.com/fluencelabs/" , website = "https://github.com/fluencelabs/"
, blueprint = bp , blueprint = bp
, modules = modules , modules = modules

View File

@ -8,25 +8,45 @@ type alias ModuleDescription =
, description : String , description : String
} }
type alias BlueprintDescription =
{ description : String
}
getSite : String -> String getSite : String -> String
getSite name = getSite name =
modulesDescription |> Dict.get name |> Maybe.map .site |> Maybe.withDefault "" modulesDescription |> Dict.get name |> Maybe.map .site |> Maybe.withDefault ""
getDescription : String -> String getModuleDescription : String -> String
getDescription name = getModuleDescription name =
modulesDescription |> Dict.get name |> Maybe.map .description |> Maybe.withDefault "Awesome module without description" modulesDescription |> Dict.get name |> Maybe.map .description |> Maybe.withDefault ""
getBlueprintDescription : String -> String
getBlueprintDescription name =
blueprintsDescription |> Dict.get name |> Maybe.map .description |> Maybe.withDefault ""
modulesDescription : Dict String ModuleDescription modulesDescription : Dict String ModuleDescription
modulesDescription = modulesDescription =
Dict.fromList Dict.fromList
[ ( "sqlite3", { site = "https://github.com/fluencelabs/sqlite", description = "Popular embeddable database compiled to WebAssembly" } ) [ ( "sqlite3", { site = "https://github.com/fluencelabs/sqlite", description = "Popular embeddable database compiled to WebAssembly, stores data in memory" } )
, ( "Message History", { site = "https://github.com/fluencelabs/aqua-demo/tree/master/services/history", description = "Stores message log, used in the Chat application" } ) , ( "sqlite", { site = "https://github.com/fluencelabs/sqlite", description = "Popular embeddable database compiled to WebAssembly, stores data in memory" } )
, ( "User List", { site = "https://github.com/fluencelabs/aqua-demo/tree/master/services/user-list", description = "Basically an address book. Used in the Chat application to store chat users" } ) , ( "history", { site = "https://github.com/fluencelabs/aqua-demo/tree/master/services/history", description = "Stores message log, used in History service" } )
, ( "redis", { site = "https://github.com/fluencelabs/redis", description = "Popular embeddable database compiled to WebAssembly" } ) , ( "userlist", { site = "https://github.com/fluencelabs/aqua-demo/tree/master/services/user-list", description = "Address book implementation module, used in User List service" } )
, ( "curl", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/curl", description = "Module that call 'curl' command" } ) , ( "redis", { site = "https://github.com/fluencelabs/redis", description = "Popular embeddable database compiled to WebAssembly, stores data in memory" } )
, ( "local_storage", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/local_storage", description = "Could be used to store data" } ) , ( "curl", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/curl", description = "Adapter module for cURL CLI utility" } )
, ( "Url Downloader", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/facade", description = "cURL adapter, allows to download anything by URL" } ) , ( "local_storage", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/local_storage", description = "Provides methods for working with file system: put and get" } )
, ( "curl_adapter", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/facade", description = "Adapter module for cURL CLI utility" } )
, ( "url_downloader", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/facade", description = "Adapter module for cURL CLI utility" } )
, ( "facade_url_downloader", { site = "https://github.com/fluencelabs/fce/tree/master/examples/url-downloader/facade", description = "Adapter module for cURL CLI utility" } )
]
blueprintsDescription : Dict String BlueprintDescription
blueprintsDescription =
Dict.fromList
[ ( "SQLite 3", { description = "Popular embeddable database compiled to WebAssembly" } )
, ( "Message History", { description = "Stores message log, used in the Chat application" } )
, ( "User List", { description = "Basically an address book. Used in the Chat application to store chat users" } )
, ( "Redis", { description = "Popular embeddable database compiled to WebAssembly" } )
, ( "URL Downloader", { description = "cURL adapter, allows to download anything by URL" } )
] ]

View File

@ -3,7 +3,7 @@ module ModulePage.View exposing (..)
import Dict exposing (Dict) import Dict exposing (Dict)
import Html exposing (Html, a, article, div, span, text) import Html exposing (Html, a, article, div, span, text)
import Html.Attributes exposing (attribute, property) import Html.Attributes exposing (attribute, property)
import Info exposing (getDescription, getSite) import Info exposing (getModuleDescription, getSite)
import Instances.View import Instances.View
import Interface.View exposing (interfaceView) import Interface.View exposing (interfaceView)
import Json.Encode exposing (string) import Json.Encode exposing (string)
@ -62,7 +62,7 @@ moduleToInfo modules id =
, id = id , id = id
, author = "Fluence Labs" , author = "Fluence Labs"
, authorPeerId = "" , authorPeerId = ""
, description = getDescription m.name , description = getModuleDescription m.name
, website = getSite m.name , website = getSite m.name
, moduleInfo = m , moduleInfo = m
} }

View File

@ -50,7 +50,7 @@ function event(name: string,peer: string,peers?: string[],identify?: string[],se
/* eslint-enable */ /* eslint-enable */
(async () => { (async () => {
// Fluence.setLogLevel('silent') Fluence.setLogLevel('silent')
const pid = await Fluence.generatePeerId(); const pid = await Fluence.generatePeerId();
const flags = genFlags(pid.toB58String()); const flags = genFlags(pid.toB58String());
@ -63,9 +63,9 @@ function event(name: string,peer: string,peers?: string[],identify?: string[],se
}); });
const eventService = new ServiceOne('event', (fnName, args: any[]) => { const eventService = new ServiceOne('event', (fnName, args: any[]) => {
console.log('event service called: ', fnName); // console.log('event service called: ', fnName);
// console.log('from: ', args[0]); // console.log('from: ', args[0]);
// console.log('event service args: ', args); console.log(`event from ${args[0]} received:`, args);
try { try {
if (fnName === 'peers_discovered') { if (fnName === 'peers_discovered') {
@ -95,6 +95,7 @@ function event(name: string,peer: string,peers?: string[],identify?: string[],se
} }
const particle = await build(client.selfPeerId, part.script, map, 45000); const particle = await build(client.selfPeerId, part.script, map, 45000);
console.log("Building a particle with AIR script: ", particle)
await client.sendParticle(particle); await client.sendParticle(particle);
}); });
})(); })();

93
src/script.ts Normal file
View File

@ -0,0 +1,93 @@
export const SCRIPT: string = `
(seq
(call %init_peer_id% ("" "load") ["relayId"] relayId)
(seq
(call %init_peer_id% ("" "load") ["knownPeers"] knownPeers)
(seq
(call %init_peer_id% ("" "load") ["clientId"] clientId)
(par
(seq
(call relayId ("op" "identity") [])
(seq
(call relayId ("op" "identify") [] ident)
(seq
(call relayId ("dist" "get_blueprints") [] blueprints)
(seq
(call relayId ("dist" "get_modules") [] modules)
(seq
(call relayId ("srv" "get_interfaces") [] interfaces)
(seq
(call relayId ("op" "identity") [])
(call %init_peer_id% ("event" "all_info") [relayId ident interfaces blueprints modules])
)
)
)
)
)
)
(par
(fold knownPeers p
(par
(seq
(call p ("op" "identity") [])
(seq
(call p ("op" "identify") [] ident)
(seq
(call p ("dist" "get_blueprints") [] blueprints)
(seq
(call p ("dist" "get_modules") [] modules)
(seq
(call p ("srv" "get_interfaces") [] interfaces)
(seq
(call relayId ("op" "identity") [])
(call %init_peer_id% ("event" "all_info") [p ident interfaces blueprints modules])
)
)
)
)
)
)
(next p)
)
)
(seq
(call relayId ("op" "identity") [])
(seq
(call relayId ("dht" "neighborhood") [clientId] neigh)
(fold neigh n
(par
(seq
(call n ("dht" "neighborhood") [clientId] moreNeigh)
(fold moreNeigh mp
(par
(seq
(call mp ("op" "identify") [] ident)
(seq
(call mp ("dist" "get_blueprints") [] blueprints)
(seq
(call mp ("dist" "get_modules") [] modules)
(seq
(call mp ("srv" "get_interfaces") [] interfaces)
(seq
(call relayId ("op" "identity") [])
(call %init_peer_id% ("event" "all_info") [mp ident interfaces blueprints modules])
)
)
)
)
)
(next mp)
)
)
)
(next n)
)
)
)
)
)
)
)
)
)
`