mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 20:24:51 -04:00
Add type hints for event streams. (#10856)
This commit is contained in:
parent
b25a494779
commit
4054dfa409
18 changed files with 169 additions and 60 deletions
|
@ -14,7 +14,7 @@
|
|||
import logging
|
||||
import random
|
||||
from collections import namedtuple
|
||||
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Set, Tuple
|
||||
from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Set, Tuple
|
||||
|
||||
from synapse.api.errors import AuthError, ShadowBanError, SynapseError
|
||||
from synapse.appservice import ApplicationService
|
||||
|
@ -23,6 +23,7 @@ from synapse.metrics.background_process_metrics import (
|
|||
wrap_as_background_process,
|
||||
)
|
||||
from synapse.replication.tcp.streams import TypingStream
|
||||
from synapse.streams import EventSource
|
||||
from synapse.types import JsonDict, Requester, UserID, get_domain_from_id
|
||||
from synapse.util.caches.stream_change_cache import StreamChangeCache
|
||||
from synapse.util.metrics import Measure
|
||||
|
@ -439,7 +440,7 @@ class TypingWriterHandler(FollowerTypingHandler):
|
|||
raise Exception("Typing writer instance got typing info over replication")
|
||||
|
||||
|
||||
class TypingNotificationEventSource:
|
||||
class TypingNotificationEventSource(EventSource[int, JsonDict]):
|
||||
def __init__(self, hs: "HomeServer"):
|
||||
self.hs = hs
|
||||
self.clock = hs.get_clock()
|
||||
|
@ -485,7 +486,13 @@ class TypingNotificationEventSource:
|
|||
return (events, handler._latest_room_serial)
|
||||
|
||||
async def get_new_events(
|
||||
self, from_key: int, room_ids: Iterable[str], **kwargs: Any
|
||||
self,
|
||||
user: UserID,
|
||||
from_key: int,
|
||||
limit: Optional[int],
|
||||
room_ids: Iterable[str],
|
||||
is_guest: bool,
|
||||
explicit_room_id: Optional[str] = None,
|
||||
) -> Tuple[List[JsonDict], int]:
|
||||
with Measure(self.clock, "typing.get_new_events"):
|
||||
from_key = int(from_key)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue