Skip to content

Commit 2fb0bf6

Browse files
authored
EventIndexer: ensure we add initial checkpoints when the db is first opened (#31448)
* EventIndex: add some documentation ... because comments are not subject to rationing. * EventIndex: rationalise addInitialCheckpoints logic * EventIndex: improve logging * use a single `logger` instance to do the prefixing * use `JSON.stringify` on the checkpoints so that the rageshakes are useful * distinguish between logger.warn and logger.debug * emit some logs if the crawler loop fails * Move check for empty database to `init` The problem with checking if the database is empty in `onSync` is that, by the time we get there, it won't be. Instead let's remember if the db was empty in `init`, and then once a sync completes, we can add the checkpoints. * Some tests for EventIndexer
1 parent 3b0bc0b commit 2fb0bf6

File tree

3 files changed

+308
-75
lines changed

3 files changed

+308
-75
lines changed

src/indexing/BaseEventIndexManager.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,23 @@ import {
1515

1616
// The following interfaces take their names and member names from seshat and the spec
1717
/* eslint-disable camelcase */
18+
19+
/** A record of a place to resume crawling events in a given room. */
1820
export interface ICrawlerCheckpoint {
21+
/** The room to be indexed */
1922
roomId: string;
20-
token: string | null;
23+
24+
/** The pagination index to resume crawling from. */
25+
token: string;
26+
27+
/**
28+
* If `fullCrawl` is false (or absent) and we find that we have already indexed the events we find, then we stop crawling.
29+
*
30+
* If `fullCrawl` is true, then we keep going until we reach the end of the room history.
31+
*/
2132
fullCrawl?: boolean;
33+
34+
/** Whether we should crawl in the forward or backward direction. */
2235
direction: Direction;
2336
}
2437

0 commit comments

Comments
 (0)