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
9cbdfb3a
Commit
9cbdfb3a
authored
5 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
Make it clear that the limit for an update_function is a target
parent
23b28266
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/replication/tcp/streams/_base.py
+9
-5
9 additions, 5 deletions
synapse/replication/tcp/streams/_base.py
with
9 additions
and
5 deletions
synapse/replication/tcp/streams/_base.py
+
9
−
5
View file @
9cbdfb3a
...
@@ -24,8 +24,8 @@ from synapse.replication.http.streams import ReplicationGetStreamUpdates
...
@@ -24,8 +24,8 @@ from synapse.replication.http.streams import ReplicationGetStreamUpdates
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
# the number of rows to request from an update_function.
MAX_EVENTS_BEHIND
=
5000
00
_STREAM_UPDATE_TARGET_ROW_COUNT
=
1
00
# Some type aliases to make things a bit easier.
# Some type aliases to make things a bit easier.
...
@@ -56,7 +56,11 @@ StreamUpdateResult = Tuple[List[Tuple[Token, StreamRow]], Token, bool]
...
@@ -56,7 +56,11 @@ StreamUpdateResult = Tuple[List[Tuple[Token, StreamRow]], Token, bool]
# * from_token: the previous stream token: the starting point for fetching the
# * from_token: the previous stream token: the starting point for fetching the
# updates
# updates
# * to_token: the new stream token: the point to get updates up to
# * to_token: the new stream token: the point to get updates up to
# * limit: the maximum number of rows to return
# * target_row_count: a target for the number of rows to be returned.
#
# The update_function is expected to return up to _approximately_ target_row_count rows.
# If there are more updates available, it should set `limited` in the result, and
# it will be called again to get the next batch.
#
#
UpdateFunction
=
Callable
[[
Token
,
Token
,
int
],
Awaitable
[
StreamUpdateResult
]]
UpdateFunction
=
Callable
[[
Token
,
Token
,
int
],
Awaitable
[
StreamUpdateResult
]]
...
@@ -138,7 +142,7 @@ class Stream(object):
...
@@ -138,7 +142,7 @@ class Stream(object):
return
updates
,
current_token
,
limited
return
updates
,
current_token
,
limited
async
def
get_updates_since
(
async
def
get_updates_since
(
self
,
from_token
:
Token
,
upto_token
:
Token
,
limit
:
int
=
100
self
,
from_token
:
Token
,
upto_token
:
Token
)
->
StreamUpdateResult
:
)
->
StreamUpdateResult
:
"""
Like get_updates except allows specifying from when we should
"""
Like get_updates except allows specifying from when we should
stream updates
stream updates
...
@@ -156,7 +160,7 @@ class Stream(object):
...
@@ -156,7 +160,7 @@ class Stream(object):
return
[],
upto_token
,
False
return
[],
upto_token
,
False
updates
,
upto_token
,
limited
=
await
self
.
update_function
(
updates
,
upto_token
,
limited
=
await
self
.
update_function
(
from_token
,
upto_token
,
limit
,
from_token
,
upto_token
,
_STREAM_UPDATE_TARGET_ROW_COUNT
,
)
)
return
updates
,
upto_token
,
limited
return
updates
,
upto_token
,
limited
...
...
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