Convert state and stream stores and related code to async (#8194)

This commit is contained in:
Patrick Cloke 2020-08-28 09:37:55 -04:00 committed by GitHub
parent b055dc9322
commit aec7085179
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 45 deletions

View file

@ -333,7 +333,7 @@ class StateGroupStorage(object):
def __init__(self, hs, stores):
self.stores = stores
def get_state_group_delta(self, state_group: int):
async def get_state_group_delta(self, state_group: int):
"""Given a state group try to return a previous group and a delta between
the old and the new.
@ -341,11 +341,11 @@ class StateGroupStorage(object):
state_group: The state group used to retrieve state deltas.
Returns:
Deferred[Tuple[Optional[int], Optional[StateMap[str]]]]:
Tuple[Optional[int], Optional[StateMap[str]]]:
(prev_group, delta_ids)
"""
return self.stores.state.get_state_group_delta(state_group)
return await self.stores.state.get_state_group_delta(state_group)
async def get_state_groups_ids(
self, _room_id: str, event_ids: Iterable[str]
@ -525,7 +525,7 @@ class StateGroupStorage(object):
state_filter: The state filter used to fetch state from the database.
Returns:
A deferred dict from (type, state_key) -> state_event
A dict from (type, state_key) -> state_event
"""
state_map = await self.get_state_ids_for_events([event_id], state_filter)
return state_map[event_id]
@ -546,14 +546,14 @@ class StateGroupStorage(object):
"""
return self.stores.state._get_state_for_groups(groups, state_filter)
def store_state_group(
async def store_state_group(
self,
event_id: str,
room_id: str,
prev_group: Optional[int],
delta_ids: Optional[dict],
current_state_ids: dict,
):
) -> int:
"""Store a new set of state, returning a newly assigned state group.
Args:
@ -567,8 +567,8 @@ class StateGroupStorage(object):
to event_id.
Returns:
Deferred[int]: The state group ID
The state group ID
"""
return self.stores.state.store_state_group(
return await self.stores.state.store_state_group(
event_id, room_id, prev_group, delta_ids, current_state_ids
)