Skip to content
Snippets Groups Projects
Commit 5edc6324 authored by Iiro Rastas's avatar Iiro Rastas
Browse files

Add a get_configurable RPC call

parent ee572ccd
No related branches found
No related tags found
1 merge request!203Resolves #262 and resolves #126
Pipeline #17260 passed
...@@ -58,6 +58,8 @@ class Master { ...@@ -58,6 +58,8 @@ class Master {
ftl::config::json_t get(const ftl::UUID &peer, const std::string &uri); ftl::config::json_t get(const ftl::UUID &peer, const std::string &uri);
ftl::config::json_t getConfigurable(const ftl::UUID &peer, const std::string &uri);
void watch(const std::string &uri, std::function<void()> f); void watch(const std::string &uri, std::function<void()> f);
Eigen::Matrix4d getPose(const std::string &uri); Eigen::Matrix4d getPose(const std::string &uri);
......
...@@ -40,6 +40,10 @@ Master::Master(Configurable *root, Universe *net) ...@@ -40,6 +40,10 @@ Master::Master(Configurable *root, Universe *net)
return ftl::config::resolve(uri, false).dump(); return ftl::config::resolve(uri, false).dump();
}); });
net->bind("get_configurable", [](const std::string &uri) -> std::string {
return ftl::config::find(uri)->getConfig().dump();
});
net->bind("list_configurables", []() { net->bind("list_configurables", []() {
return ftl::config::list(); return ftl::config::list();
}); });
...@@ -76,7 +80,7 @@ Master::Master(Configurable *root, Universe *net) ...@@ -76,7 +80,7 @@ Master::Master(Configurable *root, Universe *net)
for (auto c : cs) { for (auto c : cs) {
//LOG(INFO) << "NET CONFIG: " << c; //LOG(INFO) << "NET CONFIG: " << c;
ftl::config::json_t *configuration = new ftl::config::json_t; ftl::config::json_t *configuration = new ftl::config::json_t;
*configuration = get(peer, c); *configuration = getConfigurable(peer, c);
if (!configuration->empty()) { if (!configuration->empty()) {
ftl::NetConfigurable *nc = new ftl::NetConfigurable(peer, c, *this, *configuration); ftl::NetConfigurable *nc = new ftl::NetConfigurable(peer, c, *this, *configuration);
peerConfigurables_[peer].push_back(nc); peerConfigurables_[peer].push_back(nc);
...@@ -166,6 +170,10 @@ json_t Master::get(const ftl::UUID &peer, const string &uri) { ...@@ -166,6 +170,10 @@ json_t Master::get(const ftl::UUID &peer, const string &uri) {
return json_t::parse(net_->call<string>(peer, "get_cfg", uri)); return json_t::parse(net_->call<string>(peer, "get_cfg", uri));
} }
json_t Master::getConfigurable(const ftl::UUID &peer, const string &uri) {
return json_t::parse(net_->call<string>(peer, "get_configurable", uri));
}
void Master::watch(const string &uri, function<void()> f) { void Master::watch(const string &uri, function<void()> f) {
} }
......
...@@ -12,5 +12,5 @@ void ftl::NetConfigurable::inject(const std::string &name, nlohmann::json &value ...@@ -12,5 +12,5 @@ void ftl::NetConfigurable::inject(const std::string &name, nlohmann::json &value
} }
void ftl::NetConfigurable::refresh() { void ftl::NetConfigurable::refresh() {
(*config_) = ctrl.get(peer, suri); (*config_) = ctrl.getConfigurable(peer, suri);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment