mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-30 21:12:45 +00:00
de-MSC-ifying space summaries (MSC2946) (#3134)
- This PR moves and refactors the [code](https://github.com/matrix-org/dendrite/blob/main/setup/mscs/msc2946/msc2946.go) for [MSC2946](https://github.com/matrix-org/matrix-spec-proposals/pull/2946) ('Space Summaries') to integrate it into the rest of the codebase. - Means space summaries are no longer hidden behind an MSC flag - Solves #3096 Signed-off-by: Sam Wedgwood <sam@wedgwood.dev>
This commit is contained in:
parent
297479ea49
commit
9582827493
39 changed files with 1034 additions and 810 deletions
|
@ -8,6 +8,7 @@ type RoomServerCaches interface {
|
|||
RoomServerNIDsCache
|
||||
RoomVersionCache
|
||||
RoomServerEventsCache
|
||||
RoomHierarchyCache
|
||||
EventStateKeyCache
|
||||
EventTypeCache
|
||||
}
|
||||
|
|
|
@ -2,15 +2,16 @@ package caching
|
|||
|
||||
import "github.com/matrix-org/gomatrixserverlib/fclient"
|
||||
|
||||
type SpaceSummaryRoomsCache interface {
|
||||
GetSpaceSummary(roomID string) (r fclient.MSC2946SpacesResponse, ok bool)
|
||||
StoreSpaceSummary(roomID string, r fclient.MSC2946SpacesResponse)
|
||||
// RoomHierarchy cache caches responses to federated room hierarchy requests (A.K.A. 'space summaries')
|
||||
type RoomHierarchyCache interface {
|
||||
GetRoomHierarchy(roomID string) (r fclient.RoomHierarchyResponse, ok bool)
|
||||
StoreRoomHierarchy(roomID string, r fclient.RoomHierarchyResponse)
|
||||
}
|
||||
|
||||
func (c Caches) GetSpaceSummary(roomID string) (r fclient.MSC2946SpacesResponse, ok bool) {
|
||||
return c.SpaceSummaryRooms.Get(roomID)
|
||||
func (c Caches) GetRoomHierarchy(roomID string) (r fclient.RoomHierarchyResponse, ok bool) {
|
||||
return c.RoomHierarchies.Get(roomID)
|
||||
}
|
||||
|
||||
func (c Caches) StoreSpaceSummary(roomID string, r fclient.MSC2946SpacesResponse) {
|
||||
c.SpaceSummaryRooms.Set(roomID, r)
|
||||
func (c Caches) StoreRoomHierarchy(roomID string, r fclient.RoomHierarchyResponse) {
|
||||
c.RoomHierarchies.Set(roomID, r)
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ type Caches struct {
|
|||
RoomServerEventTypes Cache[types.EventTypeNID, string] // eventType NID -> eventType
|
||||
FederationPDUs Cache[int64, *types.HeaderedEvent] // queue NID -> PDU
|
||||
FederationEDUs Cache[int64, *gomatrixserverlib.EDU] // queue NID -> EDU
|
||||
SpaceSummaryRooms Cache[string, fclient.MSC2946SpacesResponse] // room ID -> space response
|
||||
RoomHierarchies Cache[string, fclient.RoomHierarchyResponse] // room ID -> space response
|
||||
LazyLoading Cache[lazyLoadingCacheKey, string] // composite key -> event ID
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ func NewRistrettoCache(maxCost config.DataUnit, maxAge time.Duration, enableProm
|
|||
MaxAge: lesserOf(time.Hour/2, maxAge),
|
||||
},
|
||||
},
|
||||
SpaceSummaryRooms: &RistrettoCachePartition[string, fclient.MSC2946SpacesResponse]{ // room ID -> space response
|
||||
RoomHierarchies: &RistrettoCachePartition[string, fclient.RoomHierarchyResponse]{ // room ID -> space response
|
||||
cache: cache,
|
||||
Prefix: spaceSummaryRoomsCache,
|
||||
Mutable: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue