class PyModuleRegistry
{
private:
- mutable Mutex lock{"PyModuleRegistry::lock"};
+ mutable ceph::mutex lock = ceph::make_mutex("PyModuleRegistry::lock");
LogChannelRef clog;
std::map<std::string, PyModuleRef> modules;
+ std::multimap<std::string, entity_addrvec_t> clients;
std::unique_ptr<ActivePyModules> active_modules;
std::unique_ptr<StandbyPyModules> standby_modules;
* Get references to all modules (whether they have loaded and/or
* errored) or not.
*/
- std::list<PyModuleRef> get_modules() const
+ auto get_modules() const
{
+ std::vector<PyModuleRef> modules_out;
std::lock_guard l(lock);
- std::list<PyModuleRef> modules_out;
for (const auto &i : modules) {
modules_out.push_back(i.second);
}
ceph_assert(active_modules);
return active_modules->get_services();
}
+
+ void register_client(std::string_view name, entity_addrvec_t addrs)
+ {
+ clients.emplace(std::string(name), std::move(addrs));
+ }
+ void unregister_client(std::string_view name, const entity_addrvec_t& addrs)
+ {
+ auto itp = clients.equal_range(std::string(name));
+ for (auto it = itp.first; it != itp.second; ++it) {
+ if (it->second == addrs) {
+ it = clients.erase(it);
+ }
+ }
+ }
+
+ auto get_clients() const
+ {
+ std::scoped_lock l(lock);
+ std::vector<entity_addrvec_t> v;
+ for (const auto& p : clients) {
+ v.push_back(p.second);
+ }
+ return v;
+ }
+
// <<< (end of ActivePyModules cheeky call-throughs)
};