Commit 35af5369 authored by Dominik Charousset's avatar Dominik Charousset

Allow URI-formatted group identifiers

parent 2776da90
...@@ -53,6 +53,11 @@ public: ...@@ -53,6 +53,11 @@ public:
// -- observers -------------------------------------------------------------- // -- observers --------------------------------------------------------------
/// Get a handle to the group associated with given URI scheme.
/// @threadsafe
/// @experimental
expected<group> get(std::string group_uri) const;
/// Get a handle to the group associated with /// Get a handle to the group associated with
/// `identifier` from the module `mod_name`. /// `identifier` from the module `mod_name`.
/// @threadsafe /// @threadsafe
......
...@@ -85,7 +85,7 @@ std::string to_string(const group& x) { ...@@ -85,7 +85,7 @@ std::string to_string(const group& x) {
if (x == invalid_group) if (x == invalid_group)
return "<invalid-group>"; return "<invalid-group>";
std::string result = x.get()->module().name(); std::string result = x.get()->module().name();
result += "/"; result += ":";
result += x.get()->identifier(); result += x.get()->identifier();
return result; return result;
} }
......
...@@ -469,6 +469,18 @@ group group_manager::anonymous() const { ...@@ -469,6 +469,18 @@ group group_manager::anonymous() const {
return *get_module("local")->get(id); return *get_module("local")->get(id);
} }
expected<group> group_manager::get(std::string group_uri) const {
CAF_LOG_TRACE(CAF_ARG(module_name) << CAF_ARG(group_identifier));
// URI parsing is pretty much a brute-force approach, no actual validation yet
auto p = group_uri.find(':');
if (p == std::string::npos)
return sec::invalid_argument;
auto group_id = group_uri.substr(p + 1);
// erase all but the scheme part from the URI and use that as module name
group_uri.erase(p);
return get(group_uri, group_id);
}
expected<group> group_manager::get(const std::string& module_name, expected<group> group_manager::get(const std::string& module_name,
const std::string& group_identifier) const { const std::string& group_identifier) const {
CAF_LOG_TRACE(CAF_ARG(module_name) << CAF_ARG(group_identifier)); CAF_LOG_TRACE(CAF_ARG(module_name) << CAF_ARG(group_identifier));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment