mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Make it clear that the limit for an update_function is a target
This commit is contained in:
parent
23b28266ac
commit
9cbdfb3a2f
@ -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 = 500000
|
_STREAM_UPDATE_TARGET_ROW_COUNT = 100
|
||||||
|
|
||||||
|
|
||||||
# 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]
|
|||||||
# * 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):
|
|||||||
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):
|
|||||||
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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user