0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00
construct/include/ircd/m/room
2022-08-17 13:05:39 -07:00
..
aliases.h ircd:Ⓜ️ Simplify various interfaces using string rather than net::hostport remotes. 2020-03-07 17:17:46 -08:00
auth.h ircd:Ⓜ️:room::auth: Allow an incorrect fifth event; warning remains. 2020-05-01 10:10:17 -07:00
bootstrap.h ircd:Ⓜ️:room::bootstrap: Adjust interface allowing for multiple remote server arguments. 2020-04-21 19:22:06 -07:00
content.h ircd:Ⓜ️:room::content: Move prefetch buffer to class member. 2022-08-05 18:38:32 -07:00
events.h ircd:Ⓜ️:room::events::missing: Dedup inner loop; optimize w/ parallel query. 2022-07-30 20:58:59 -07:00
head.h ircd:Ⓜ️:room::head: Add fetch interface. 2020-11-05 22:10:54 -08:00
head_fetch.h ircd:Ⓜ️:room::head::fetch: Refactor one() convenience interface; add abstract overload. 2020-12-09 02:16:50 -08:00
head_generate.h ircd:Ⓜ️:room::head: Split generate into header. 2020-11-05 22:10:54 -08:00
members.h ircd:Ⓜ️:room::members: Eliminate unnecessary query to the room state. 2020-06-14 22:05:15 -07:00
message.h ircd:Ⓜ️:room::message: Add interface for edit contents. 2022-08-16 13:43:00 -07:00
messages.h ircd:Ⓜ️:room: Add interface to room messages. 2022-08-17 13:05:39 -07:00
origins.h ircd:Ⓜ️:room::origins: Simplify callstack; remove unused iteration. 2020-03-09 14:41:36 -07:00
power.h ircd:Ⓜ️:room::power: Use conf items to seed all default values. 2020-05-01 10:10:17 -07:00
README.md ircd:Ⓜ️:room: Rename room::messages to room::events. 2019-08-30 14:43:19 -07:00
room.h ircd:Ⓜ️:room: Add interface to room messages. 2022-08-17 13:05:39 -07:00
server_acl.h ircd:Ⓜ️:room::server_acl: Propagate exceptions through check(). 2019-09-13 14:10:27 -07:00
state.h ircd:Ⓜ️:room::state: Add fetch interface similar to room::head; w/ console cmd. 2020-11-20 18:28:32 -08:00
state_fetch.h ircd:Ⓜ️:room::state: Add fetch interface similar to room::head; w/ console cmd. 2020-11-20 18:28:32 -08:00
state_history.h ircd:Ⓜ️:room::state::history: Add event_idx class member; improve 6768c23811 condition. 2020-12-08 03:33:06 -08:00
state_space.h ircd:Ⓜ️:room::state: Add prefetch() support to state::history/state::space. 2019-09-18 13:30:15 -07:00
stats.h ircd:Ⓜ️:room: Start a room statistics interface. 2019-02-25 18:20:48 -08:00
type.h ircd:Ⓜ️:room::type: Add prefix matching option. 2020-03-24 14:50:41 -07:00

Matrix Room Interface

The headers in this directory as well as ../room.h comprise the API for Matrix rooms. These interfaces may conduct IO for both the local database and the network; many calls may block an ircd::ctx for these purposes.

A room is composed from a timeline of events. We use several key-value tables as the database for room in addition to the raw event data itself.

  • room_events This is the timeline for room events. We sort the keys of this table by an event's depth. This table allows us to scan the room's events as a collection. See: m::room::events.

  • room_state This is the present state table for a room. We sort the keys of this table by (type,state_key). See: m::room::state.

  • room_joined This is the present joined members list. It is technically redundant to that aspect of the room_state table but it is more efficient for us to maintain a separate table. See: m::room::origins which uses this table. Other interfaces are internally optimized by this table for some calls.

  • room_head This is the collection of forward extremities (unreferenced) for a room. This is a fast-moving table that would otherwise be just a list in RAM; however persisting this through the database prevents recalculating it on startup.

  • state_node This is a key-value store of nodes in a b-tree which is how we efficiently represent the state of a room at any past event. See: m::state subsystem. Note that m::state should not be confused with m::room::state. The latter is the user interface to room state which you are probably looking for; the former is the actual implementation of the b-tree and low-level details.

Sending & Transmission

The write interface for rooms is aggregated almost entirely in the index header ../room.h. These calls all converge on a single function commit which sends a partial event to a room via m::vm evaluation.

These calls all take a room structure as an argument which will be further explained in the Reading section. For now know that the room argument is lightweight and trivially constructed from a room_id. It can take a pointer to m::vm::eval options which offer extensive control over the transmission process.

All of the transmitting calls will block an ircd::ctx but the extent to which they do is configurable via the eval options. All of the calls return an event::id::buf of the event which they just committed to the room.

Above the lowest-level commit() function there are two mid-level send() suites. One suite creates and sends a state event to the room, the other creates and sends a non-state event. The overloads are distinguished by an extra state_key argument for the former.

Above the mid-level send() suites there is an accumulation of higher-level convenience functions, like message() and join() et al.

Reading & Access

The rest of these interfaces are read-only interfaces which present aspects of the room as efficiently as possible.

m::room

The principal structure is m::room in room/room.h. There are no ways to change an actual room through this interface, but an instance can be used with calls that do. Instances of room are lightweight, maintaining a reference to a room_id and an optional event_id. The data behind those references must stay in scope for the duration of the room instance.

When a room instance is used either for reading or writing, the event_id indicates a cursory position in the room to conduct operations. The room will be represented at that event_id. If no event_id is specified, the room will be represented at the latest "present" state; note the present state of a room is subject to change between calls.

The room class interface offers a convenience frontend which brings together the basic elements of the room::messages and room::state interfaces. These have different characteristics.

Other interfaces

The remainder of room/ is comprised of specialized interfaces which operate efficiently and friendly for their specific purpose.