mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-13 08:52:11 -04:00
Add some type hints to datastore (#12485)
This commit is contained in:
parent
63ba9ba38b
commit
b76f1a4d5f
12 changed files with 188 additions and 84 deletions
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import TYPE_CHECKING, Dict, Iterable, List, Tuple, cast
|
||||
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Tuple, cast
|
||||
|
||||
from synapse.api.presence import PresenceState, UserPresenceState
|
||||
from synapse.replication.tcp.streams import PresenceStream
|
||||
|
@ -103,7 +103,9 @@ class PresenceStore(PresenceBackgroundUpdateStore):
|
|||
prefilled_cache=presence_cache_prefill,
|
||||
)
|
||||
|
||||
async def update_presence(self, presence_states) -> Tuple[int, int]:
|
||||
async def update_presence(
|
||||
self, presence_states: List[UserPresenceState]
|
||||
) -> Tuple[int, int]:
|
||||
assert self._can_persist_presence
|
||||
|
||||
stream_ordering_manager = self._presence_id_gen.get_next_mult(
|
||||
|
@ -121,7 +123,10 @@ class PresenceStore(PresenceBackgroundUpdateStore):
|
|||
return stream_orderings[-1], self._presence_id_gen.get_current_token()
|
||||
|
||||
def _update_presence_txn(
|
||||
self, txn: LoggingTransaction, stream_orderings, presence_states
|
||||
self,
|
||||
txn: LoggingTransaction,
|
||||
stream_orderings: List[int],
|
||||
presence_states: List[UserPresenceState],
|
||||
) -> None:
|
||||
for stream_id, state in zip(stream_orderings, presence_states):
|
||||
txn.call_after(
|
||||
|
@ -405,7 +410,13 @@ class PresenceStore(PresenceBackgroundUpdateStore):
|
|||
self._presence_on_startup = []
|
||||
return active_on_startup
|
||||
|
||||
def process_replication_rows(self, stream_name, instance_name, token, rows) -> None:
|
||||
def process_replication_rows(
|
||||
self,
|
||||
stream_name: str,
|
||||
instance_name: str,
|
||||
token: int,
|
||||
rows: Iterable[Any],
|
||||
) -> None:
|
||||
if stream_name == PresenceStream.NAME:
|
||||
self._presence_id_gen.advance(instance_name, token)
|
||||
for row in rows:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue