mirror of
https://github.com/matrix-construct/construct
synced 2025-01-16 01:26:58 +01:00
ircd:Ⓜ️:room::origins: Add interface to count room servers online/error.
This commit is contained in:
parent
4178f40ee1
commit
b17b508c2a
2 changed files with 33 additions and 0 deletions
|
@ -29,6 +29,8 @@ struct ircd::m::room::origins
|
|||
void for_each(const closure &view) const;
|
||||
bool has(const string_view &origin) const;
|
||||
bool only(const string_view &origin) const;
|
||||
size_t count_online() const;
|
||||
size_t count_error() const;
|
||||
size_t count() const;
|
||||
|
||||
// select an origin in the room at random; use proffer to refuse and try another.
|
||||
|
|
|
@ -3535,6 +3535,37 @@ const
|
|||
return ret;
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::m::room::origins::count_error()
|
||||
const
|
||||
{
|
||||
size_t ret{0};
|
||||
for_each([&ret](const string_view &server)
|
||||
{
|
||||
ret += !empty(server::errmsg(server));
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::m::room::origins::count_online()
|
||||
const
|
||||
{
|
||||
ssize_t ret
|
||||
{
|
||||
0 - ssize_t(count_error())
|
||||
};
|
||||
|
||||
for_each([&ret](const string_view &hostport)
|
||||
{
|
||||
ret += bool(server::exists(hostport));
|
||||
});
|
||||
|
||||
assert(ret >= 0L);
|
||||
return std::max(ret, 0L);
|
||||
}
|
||||
|
||||
/// Tests if argument is the only origin in the room.
|
||||
/// If a zero or more than one origins exist, returns false. If the only origin
|
||||
/// in the room is the argument origin, returns true.
|
||||
|
|
Loading…
Reference in a new issue