mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd:Ⓜ️:room::events: Add viewport metric concept; conf item.
This commit is contained in:
parent
c570e04622
commit
6831f195aa
2 changed files with 46 additions and 3 deletions
|
@ -11,6 +11,14 @@
|
|||
#pragma once
|
||||
#define HAVE_IRCD_M_ROOM_EVENTS_H
|
||||
|
||||
// The "viewport" is comprised of events starting from the tophead (most recent
|
||||
// in room timeline) and covering about ~20 events leading up to that. Note
|
||||
// that this is a completely ad hoc and configurable server value. Events in
|
||||
// the viewport must be eval'ed and synced to clients in the order they will
|
||||
// be displayed. Events not in the viewport are not /synced to clients and any
|
||||
// client request provides event ordering: thus older events (backfills, etc)
|
||||
// can be eval'ed without this constraint.
|
||||
//
|
||||
// The "sounding" is the depth of the first gap. In any attempt to trace
|
||||
// the room timeline from the tophead to the m.room.create event: the sounding
|
||||
// is the [highest number] depth preventing that.
|
||||
|
@ -24,6 +32,7 @@
|
|||
|
||||
namespace ircd::m
|
||||
{
|
||||
std::pair<int64_t, event::idx> viewport(const room &);
|
||||
std::pair<int64_t, event::idx> sounding(const room &); // Last missing (one)
|
||||
std::pair<int64_t, event::idx> twain(const room &);
|
||||
std::pair<int64_t, event::idx> hazard(const room &); // First missing (one)
|
||||
|
@ -43,6 +52,8 @@ struct ircd::m::room::events
|
|||
struct horizon;
|
||||
struct missing;
|
||||
|
||||
static conf::item<size_t> viewport_size;
|
||||
|
||||
m::room room;
|
||||
db::domain::const_iterator it;
|
||||
event::fetch _event;
|
||||
|
|
|
@ -14,9 +14,41 @@ IRCD_MODULE
|
|||
"Matrix room library"
|
||||
};
|
||||
|
||||
//
|
||||
// tools
|
||||
//
|
||||
IRCD_MODULE_EXPORT_DATA
|
||||
decltype(ircd::m::room::events::viewport_size)
|
||||
ircd::m::room::events::viewport_size
|
||||
{
|
||||
{ "name", "ircd.m.room.events.viewport.size" },
|
||||
{ "default", 24L },
|
||||
};
|
||||
|
||||
std::pair<int64_t, ircd::m::event::idx>
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::viewport(const room &room)
|
||||
{
|
||||
std::pair<int64_t, m::event::idx> ret
|
||||
{
|
||||
-1, 0
|
||||
};
|
||||
|
||||
m::room::events it
|
||||
{
|
||||
room
|
||||
};
|
||||
|
||||
const size_t &max
|
||||
{
|
||||
room::events::viewport_size
|
||||
};
|
||||
|
||||
for(size_t i(0); it && i < max; --it, ++i)
|
||||
{
|
||||
ret.first = it.depth();
|
||||
ret.second = it.event_idx();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::pair<int64_t, ircd::m::event::idx>
|
||||
IRCD_MODULE_EXPORT
|
||||
|
|
Loading…
Reference in a new issue