mirror of
https://github.com/matrix-construct/construct
synced 2024-09-27 11:18:51 +02: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;
|
void for_each(const closure &view) const;
|
||||||
bool has(const string_view &origin) const;
|
bool has(const string_view &origin) const;
|
||||||
bool only(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;
|
size_t count() const;
|
||||||
|
|
||||||
// select an origin in the room at random; use proffer to refuse and try another.
|
// select an origin in the room at random; use proffer to refuse and try another.
|
||||||
|
|
|
@ -3535,6 +3535,37 @@ const
|
||||||
return ret;
|
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.
|
/// 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
|
/// If a zero or more than one origins exist, returns false. If the only origin
|
||||||
/// in the room is the argument origin, returns true.
|
/// in the room is the argument origin, returns true.
|
||||||
|
|
Loading…
Reference in a new issue