-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds shared-state rpcd data,error output format and shared-state-async rpcd reimplementation #1103
Adds shared-state rpcd data,error output format and shared-state-async rpcd reimplementation #1103
Conversation
This looks good :D Do you think we should include it in the next release candidate once it is merged? Do you plan to move all this to OpenWrt repositories at some point? |
imo should be included! This makes the shared state calls more consistent... But, it will break the compatibility with older versions. Are this packages already included on the actual version?
I think shared state not exists on the OWRT repos no? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Compatibility?
Shared state does not exist on OpenWrt repository, correct. But it should be there. It should not be here. In case there is any shared-state developer willing to manage the migration, maybe some people from OpenWrt could help...? @aparcar |
@ilario shared-state developers and it is pretty tied to libre-mesh stuff altought it might be used indipendently, at this stage of development, moving it to openwrt repository could be premature IMHO, but once shared-state-async is more stable and completely substitute shared-state Lua, it might be good to move it in openwrt-packages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few improvements and it is ready to merge
end | ||
end | ||
#!/bin/sh | ||
# --[[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line should now be blank
# Copyright (C) 2024 Asociacion Civil Altermundi <[email protected]> | ||
|
||
# SPDX-License-Identifier: AGPL-3.0-only | ||
# ]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this like show now go away
call) | ||
# source jshn shell library | ||
. /usr/share/libubox/jshn.sh | ||
read nmsg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What this variable name means? Either I miss something or a more readable name should be used (always remember what will I understand when I'll reopen this file a couple years after?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change it to match the name of the same variable in all the other rpcd scripts "msg"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using shell instead of Lua resulted in a much nicer code as anticipated :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
much better, I was worried about json parsing but some else was also worried before me.
Shared State rpcd/ubus interface is used only by lime app so they go together. |
Ubus interface for shared state
current implementations of rpcd for shared-state are inconsistent this new implementation adds a consistent format across the three implementations (shared-state, shared-state-async, shared-state-multiwriter )
In every case calls to shared state get or sync will return a json object wit this format
Also this new implementation for shared-state-async uses a shell script to simplify the implementation
Ubus interface for shared state async
ubus -S call shared-state-async get '{"data_type": "bat-hosts"}'
ubus -S call shared-state-async get '{"data_type": "bat-hosss"}'
ubus -S call shared-state-async sync '{"data_type": "bat-hosts"}'
ubus -S call shared-state-async sync '{"data_type": "bat-hosss"}'
ubus -S call shared-state-async sync '{"data_type": "bat-hostss", "peers_ip":"10.13.30.20"}'
ubus -S call shared-state-async sync '{"data_type": "bat-hosts", "peers_ip":"10.13.30.20"}'
ubus -S call shared-state-async sync '{"data_type": "bat-hosts", "peers_ip":"127.0.0.1"}'
Ubus interface for shared state and shared state Multiwriter
Get the list of available methods using:
ubus -v list shared-state
Get wifi links information:
ubus -S call shared-state getFromSharedState '{"data_type": "wifi_links_info" }'
Write information that is common to every all the network:
ubus -S call shared-state insertIntoSharedStateMultiWriter '{"data_type": "ref_state_wifi_links", "json": {"primero":{"bleachTTL":27}}}'
Get the information in the same node:
ubus -S call shared-state getFromSharedStateMultiWriter '{"data_type": "ref_state_wifi_links"}'
Get the info in another node, before getting the information the others need to sync on the same topic.
This has to be done before reading and data types usually do it in a cron job.
shared-state-multiwriter sync ref_state_wifi_links
ubus -S call shared-state getFromSharedStateMultiWriter '{"data_type": "ref_state_wifi_links" }'