|
|
@ -1024,28 +1024,31 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore): |
|
|
|
"after": {"event_ids": events_after, "token": end_token}, |
|
|
|
"after": {"event_ids": events_after, "token": end_token}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async def get_all_new_events_stream( |
|
|
|
async def get_all_new_event_ids_stream( |
|
|
|
self, from_id: int, current_id: int, limit: int, get_prev_content: bool = False |
|
|
|
self, |
|
|
|
) -> Tuple[int, List[EventBase], Dict[str, Optional[int]]]: |
|
|
|
from_id: int, |
|
|
|
|
|
|
|
current_id: int, |
|
|
|
|
|
|
|
limit: int, |
|
|
|
|
|
|
|
) -> Tuple[int, Dict[str, Optional[int]]]: |
|
|
|
"""Get all new events |
|
|
|
"""Get all new events |
|
|
|
|
|
|
|
|
|
|
|
Returns all events with from_id < stream_ordering <= current_id. |
|
|
|
Returns all event ids with from_id < stream_ordering <= current_id. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
from_id: the stream_ordering of the last event we processed |
|
|
|
from_id: the stream_ordering of the last event we processed |
|
|
|
current_id: the stream_ordering of the most recently processed event |
|
|
|
current_id: the stream_ordering of the most recently processed event |
|
|
|
limit: the maximum number of events to return |
|
|
|
limit: the maximum number of events to return |
|
|
|
get_prev_content: whether to fetch previous event content |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns: |
|
|
|
Returns: |
|
|
|
A tuple of (next_id, events, event_to_received_ts), where `next_id` |
|
|
|
A tuple of (next_id, event_to_received_ts), where `next_id` |
|
|
|
is the next value to pass as `from_id` (it will either be the |
|
|
|
is the next value to pass as `from_id` (it will either be the |
|
|
|
stream_ordering of the last returned event, or, if fewer than `limit` |
|
|
|
stream_ordering of the last returned event, or, if fewer than `limit` |
|
|
|
events were found, the `current_id`). The `event_to_received_ts` is |
|
|
|
events were found, the `current_id`). The `event_to_received_ts` is |
|
|
|
a dictionary mapping event ID to the event `received_ts`. |
|
|
|
a dictionary mapping event ID to the event `received_ts`, sorted by ascending |
|
|
|
|
|
|
|
stream_ordering. |
|
|
|
""" |
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
def get_all_new_events_stream_txn( |
|
|
|
def get_all_new_event_ids_stream_txn( |
|
|
|
txn: LoggingTransaction, |
|
|
|
txn: LoggingTransaction, |
|
|
|
) -> Tuple[int, Dict[str, Optional[int]]]: |
|
|
|
) -> Tuple[int, Dict[str, Optional[int]]]: |
|
|
|
sql = ( |
|
|
|
sql = ( |
|
|
@ -1070,15 +1073,10 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore): |
|
|
|
return upper_bound, event_to_received_ts |
|
|
|
return upper_bound, event_to_received_ts |
|
|
|
|
|
|
|
|
|
|
|
upper_bound, event_to_received_ts = await self.db_pool.runInteraction( |
|
|
|
upper_bound, event_to_received_ts = await self.db_pool.runInteraction( |
|
|
|
"get_all_new_events_stream", get_all_new_events_stream_txn |
|
|
|
"get_all_new_event_ids_stream", get_all_new_event_ids_stream_txn |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
events = await self.get_events_as_list( |
|
|
|
|
|
|
|
event_to_received_ts.keys(), |
|
|
|
|
|
|
|
get_prev_content=get_prev_content, |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
return upper_bound, events, event_to_received_ts |
|
|
|
return upper_bound, event_to_received_ts |
|
|
|
|
|
|
|
|
|
|
|
async def get_federation_out_pos(self, typ: str) -> int: |
|
|
|
async def get_federation_out_pos(self, typ: str) -> int: |
|
|
|
if self._need_to_reset_federation_stream_positions: |
|
|
|
if self._need_to_reset_federation_stream_positions: |
|
|
|