0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-29 08:13:46 +02:00
construct/include/ircd/m/room
2023-04-21 21:40:50 -07:00
..
aliases.h ircd:Ⓜ️:room::aliases: Add has_server() optimized count(server)>0 to interface. 2023-01-24 22:44:03 -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
events.h ircd:Ⓜ️ Simplify room::events interface; separate event::fetch. 2023-02-18 16:41:33 -08: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
horizon.h ircd:Ⓜ️:room::events: Move nested interfaces out to room::. 2023-02-17 15:24:23 -08:00
iterate.h ircd:Ⓜ️:room: Rename room::content to room::iterate and abstract. 2023-02-22 16:04:12 -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: Fix reply fallback accepting non-mxid careted names. 2022-09-21 16:39:05 -07:00
messages.h ircd: Add function_bool convenience template alias. 2023-02-16 20:53:30 -08:00
missing.h ircd:Ⓜ️:room::missing: Move event::fetch out of loop body. 2023-02-22 16:04:12 -08:00
origins.h ircd:Ⓜ️:room::origins: Simplify callstack; remove unused iteration. 2020-03-09 14:41:36 -07:00
power.h ircd::util: Generalize util::boolean into returns template. 2023-02-09 19:17:45 -08:00
purge.h ircd:Ⓜ️ Add dbs::opts passed to room::purge and event::purge interfaces. 2023-02-10 23:15:47 -08:00
README.md ircd:Ⓜ️:room: Rename room::messages to room::events. 2019-08-30 14:43:19 -07:00
room.h ircd:Ⓜ️:room: Add boolean query for room type. 2023-04-21 21:40:50 -07:00
server_acl.h ircd:Ⓜ️:room::server_acl: Propagate exceptions through check(). 2019-09-13 14:10:27 -07:00
sounding.h ircd:Ⓜ️:room::events: Move nested interfaces out to room::. 2023-02-17 15:24:23 -08:00
state.h ircd:Ⓜ️:room: Add consolidated room::purge interface w/ options. 2023-02-10 12:27:52 -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.