import * as Effect from 'effect/Effect'; import * as SqlClient from 'effect/sql/SqlClient'; import type * as SqlError from 'effect/sql/SqlError'; import { Event } from '@dxos/async'; import { type DataService } from '@dxos/protocols/rpc'; /** How often the tracker reads a count while work goes on. */ export declare const BACKLOG_RECOUNT_INTERVAL = 1000; /** * The host's {@link DataService.IndexStatus} and {@link DataService.IndexActivity}, each with an event * on change. The one place index counts become progress: it decides when each count is taken (at most * once per {@link BACKLOG_RECOUNT_INTERVAL}), a count that fails leaves progress as it was, and each * kind of work ends when it does. */ export declare class IndexStatusTracker { #private; /** Each change of the status, so each is progress of a migration or rebuild. */ readonly updated: Event; readonly activityUpdated: Event; /** `recountInterval` overrides {@link BACKLOG_RECOUNT_INTERVAL}. */ constructor({ recountInterval }?: { recountInterval?: number; }); get current(): DataService.IndexStatus; get activity(): DataService.IndexActivity; setMigrating(done: number, total: number): void; /** Counts the rebuild once the stores open, which ends any migration; `count` is the backlog count from then on. */ opened(count: () => Promise): Promise; /** Whether the pass about to run counts its documents' catch-up, and the backlog after it. */ beginPass(): boolean; /** * Moves the status and catch-up on after a pass, and after a counting one (see {@link beginPass}) * takes its documents' `catchUp` and recounts the backlog. A drained pass read every document it had * to, so it ends the rebuild and catch-up. */ afterPass({ drained, catchUp }: { drained: boolean; catchUp?: number; }): Promise; /** After a full-text batch that leaves more, recounts what is left with `count` when due. */ afterFullTextBatch(count: () => Promise): Promise; /** A full-text flush ended, done or failed, and its lane with it. */ fullTextEnded(): void; } /** What {@link countIndexBacklog} found the primary indexes have not reached. */ export type IndexBacklog = { /** Documents with no cursor: the rebuild, with {@link blocks}. */ documents: number; /** Feed blocks stored before the host opened: the rebuild, with {@link documents}. */ blocks: number; /** Feed blocks stored after the host opened, as after time offline. */ catchUp: number; }; /** * The newest feed block when the host opens. Feed blocks share one insertion counter, so the blocks the * index has not read up to it stay a rebuild until it reads them, and blocks stored later are catch-up; * a feed cursor covers a whole namespace, so whether one exists cannot tell the two apart. */ export declare const readFeedPin: () => Effect.Effect; /** * What the primary indexes have not reached, under whichever primary index is furthest behind: * documents with no cursor, and the blocks of the feeds of `spaceIds` (the spaces the host has loaded, * which the indexer reads), split at `pin` (see {@link readFeedPin}). * * A document with a cursor but newer heads is not counted (heads are stored as a blob that SQL cannot * compare with a cursor); the indexing pass counts that catch-up as it reads. */ export declare const countIndexBacklog: ({ pin, spaceIds, }: { pin: number; spaceIds: readonly string[]; }) => Effect.Effect; //# sourceMappingURL=index-status.d.ts.map