Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
5acd8b5a
Unverified
Commit
5acd8b5a
authored
3 years ago
by
Patrick Cloke
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Expire old spaces summary pagination sessions. (#10574)
parent
2ae2a046
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/10574.feature
+1
-0
1 addition, 0 deletions
changelog.d/10574.feature
synapse/handlers/space_summary.py
+23
-1
23 additions, 1 deletion
synapse/handlers/space_summary.py
with
24 additions
and
1 deletion
changelog.d/10574.feature
0 → 100644
+
1
−
0
View file @
5acd8b5a
Add pagination to the spaces summary based on updates to [MSC2946](https
:
//github.com/matrix-org/matrix-doc/pull/2946).
This diff is collapsed.
Click to expand it.
synapse/handlers/space_summary.py
+
23
−
1
View file @
5acd8b5a
...
@@ -77,6 +77,8 @@ class _PaginationKey:
...
@@ -77,6 +77,8 @@ class _PaginationKey:
class
_PaginationSession
:
class
_PaginationSession
:
"""
The information that is stored for pagination.
"""
"""
The information that is stored for pagination.
"""
# The time the pagination session was created, in milliseconds.
creation_time_ms
:
int
# The queue of rooms which are still to process.
# The queue of rooms which are still to process.
room_queue
:
Deque
[
"
_RoomQueueEntry
"
]
room_queue
:
Deque
[
"
_RoomQueueEntry
"
]
# A set of rooms which have been processed.
# A set of rooms which have been processed.
...
@@ -84,6 +86,9 @@ class _PaginationSession:
...
@@ -84,6 +86,9 @@ class _PaginationSession:
class
SpaceSummaryHandler
:
class
SpaceSummaryHandler
:
# The time a pagination session remains valid for.
_PAGINATION_SESSION_VALIDITY_PERIOD_MS
=
5
*
60
*
1000
def
__init__
(
self
,
hs
:
"
HomeServer
"
):
def
__init__
(
self
,
hs
:
"
HomeServer
"
):
self
.
_clock
=
hs
.
get_clock
()
self
.
_clock
=
hs
.
get_clock
()
self
.
_auth
=
hs
.
get_auth
()
self
.
_auth
=
hs
.
get_auth
()
...
@@ -108,6 +113,21 @@ class SpaceSummaryHandler:
...
@@ -108,6 +113,21 @@ class SpaceSummaryHandler:
"
get_room_hierarchy
"
,
"
get_room_hierarchy
"
,
)
)
def
_expire_pagination_sessions
(
self
):
"""
Expire pagination session which are old.
"""
expire_before
=
(
self
.
_clock
.
time_msec
()
-
self
.
_PAGINATION_SESSION_VALIDITY_PERIOD_MS
)
to_expire
=
[]
for
key
,
value
in
self
.
_pagination_sessions
.
items
():
if
value
.
creation_time_ms
<
expire_before
:
to_expire
.
append
(
key
)
for
key
in
to_expire
:
logger
.
debug
(
"
Expiring pagination session id %s
"
,
key
)
del
self
.
_pagination_sessions
[
key
]
async
def
get_space_summary
(
async
def
get_space_summary
(
self
,
self
,
requester
:
str
,
requester
:
str
,
...
@@ -312,6 +332,8 @@ class SpaceSummaryHandler:
...
@@ -312,6 +332,8 @@ class SpaceSummaryHandler:
# If this is continuing a previous session, pull the persisted data.
# If this is continuing a previous session, pull the persisted data.
if
from_token
:
if
from_token
:
self
.
_expire_pagination_sessions
()
pagination_key
=
_PaginationKey
(
pagination_key
=
_PaginationKey
(
requested_room_id
,
suggested_only
,
max_depth
,
from_token
requested_room_id
,
suggested_only
,
max_depth
,
from_token
)
)
...
@@ -391,7 +413,7 @@ class SpaceSummaryHandler:
...
@@ -391,7 +413,7 @@ class SpaceSummaryHandler:
requested_room_id
,
suggested_only
,
max_depth
,
next_token
requested_room_id
,
suggested_only
,
max_depth
,
next_token
)
)
self
.
_pagination_sessions
[
pagination_key
]
=
_PaginationSession
(
self
.
_pagination_sessions
[
pagination_key
]
=
_PaginationSession
(
room_queue
,
processed_rooms
self
.
_clock
.
time_msec
(),
room_queue
,
processed_rooms
)
)
return
result
return
result
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment