mirror of
https://github.com/fluencelabs/fluent-pad
synced 2025-04-24 16:32:13 +00:00
Use proto-distributor to upload and test services.
Deploy and test
Step-by-step:
- build scripts and copy fresh artifacts to
artifacts
directory by a script:
cd services
./build.sh
- upload modules and create services. We need to remember a pid of a client, because some of methods in services can be called only by an owner. Some random seed for current owner:
7sHe8vxCo4BkdPNPdb8f2T8CJMgTmSvBTmeqtH9QWrar
. Use your own path to services artifacts.
# upload modules
# -n - name of a module
# -p - path to a wasm file
node -r esm . upload -n user-list -p path/to/fluent-pad/services/artifacts/user-list.wasm
node -r esm . upload -n history -p path/to/fluent-pad/services/artifacts/history.wasm
# create blueprints with this modules
# -d - list of dependencies
# -i - id of a blueprint
# -n - name of a blueprint
node -r esm . add_blueprint -d user-list -i user-list -n user-list
node -r esm . add_blueprint -d user-list -i history -n history
# create services with hardcoded seed
# -i - id of a blueprint
# -s - seed of a client that will be a creator/owner of a service
node -r esm . create_service -i user-list -s 7sHe8vxCo4BkdPNPdb8f2T8CJMgTmSvBTmeqtH9QWrar
node -r esm . create_service -i history -s 7sHe8vxCo4BkdPNPdb8f2T8CJMgTmSvBTmeqtH9QWrar
- last two command will return service ids, we need to store it somewhere
# user-list a38a396a-2b3d-4ef5-8b8b-ed448670bcfe
# history d9abbacf-6ee2-49e5-9683-536a5c931fa1
Service ids changed per every service creation.
- other hardcoded peer id
12D3KooWSaSTAV7ftrN8f5UXkB9MYnFtdpAJpgUZbV7r2XpfVsF2z
with seedG2r9BEsuaBHaDyMxGb2Bxv61PpH6r8UjKT564CdeU4BD
we will add to userlist service by air script. Save this script to a file.
(seq
(call relay ("op" "identity") [])
(seq
(call relay (userlist "join")
[user] result)
(call %init_peer_id% (returnService "") [result])
))
More about aquamarine
you can find here.
Command to send script:
node -r esm . run_air -p path/to/script -d '{"userlist":"a38a396a-2b3d-4ef5-8b8b-ed448670bcfe","history":"d9abbacf-6ee2-49e5-9683-536a5c931fa1","user":{"peer_id":"12D3KooWSaSTAV7ftrN8f5UXkB9MYnFtdpAJpgUZbV7r2XpfVsF2","relay_id":"","name":"some_name"}}' -s 7sHe8vxCo4BkdPNPdb8f2T8CJMgTmSvBTmeqtH9QWrar
- add a tetraplet by a creator to a history service.
12D3KooWBUJifCTgaxAUrcM9JysqCcS4CS8tiYH5hExbdWCAoNwb
is a peer id of a node where service deployed
Script:
(seq
(call relay ("op" "identity") [])
(seq
(call relay (history "set_tetraplet")
["12D3KooWBUJifCTgaxAUrcM9JysqCcS4CS8tiYH5hExbdWCAoNwb" "a38a396a-2b3d-4ef5-8b8b-ed448670bcfe" "is_authenticated" json_path] auth_result)
(call %init_peer_id% (returnService "") [auth_result])
))
Command:
ode -r esm . run_air -p /path/to/script -d '{"userlist":"a38a396a-2b3d-4ef5-8b8b-ed448670bcfe","history":"d9abbacf-6ee2-49e5-9683-536a5c931fa1", "json_path":"$.[\"is_authenticated\"]"}' -s 7sHe8vxCo4BkdPNPdb8f2T8CJMgTmSvBTmeqtH9QWrar
- A second user can auth and add messages after
(seq
(call relay ("op" "identity") [])
(seq
(call relay (userlist "is_authenticated")
[] status)
(seq
(call relay (history "add")
[msg status.$.["is_authenticated"]] auth_result)
(call %init_peer_id% (returnService "") [auth_result])
)))
node -r esm . run_air -p path/to-script -d '{"userlist":"a38a396a-2b3d-4ef5-8b8b-ed448670bcfe","history":"d9abbacf-6ee2-49e5-9683-536a5c931fa1", "json_path":"$.[\"is_authenticated\"]", "msg":"Hi there!"}' -s G2r9BEsuaBHaDyMxGb2Bxv61PpH6r8UjKT564CdeU4BD
- also, we can get user list by
get_users
method and messages byget_all
method