Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions backend/src/services/replayService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import { eventProcessor } from "./eventProcessor";
import { DefaultEventValidator } from "./eventValidator";
import { InMemoryRawEventStore } from "./rawEventStore";
import { InMemoryDerivedTableStore } from "./derivedTableStore";
import {
ReplayRun,
ReplayStartRequest,
ReplayPreview,
import {
ReplayRun,
ReplayStartRequest,
ReplayPreview,
ReplayAuditEntry,
ReplayStats,
RawEventStore,
DerivedTableStore,
ReplayRunStatus,
ReplayAuditEventType
ReplayAuditEventType,
} from "../types/replay";
import { SnapshotScheduler } from "./snapshotService";

export class ReplayError extends Error {
public readonly code: string;
Expand All @@ -34,6 +35,8 @@ export class ReplayService {
private readonly runTimers = new Map<string, NodeJS.Timeout>();
private readonly auditLogPath: string;
private failureAtLedger: number | null = null;
/** Optional snapshot scheduler wired in after construction. */
private snapshotScheduler: SnapshotScheduler | null = null;

private constructor(
private readonly rawEventStore: RawEventStore,
Expand All @@ -54,6 +57,14 @@ export class ReplayService {
return ReplayService.instance;
}

/**
* Wire the SnapshotScheduler so that batch boundaries are signalled for
* mid-batch snapshot detection.
*/
public setSnapshotScheduler(scheduler: SnapshotScheduler): void {
this.snapshotScheduler = scheduler;
}

public async startReplay(
payload: ReplayStartRequest,
actor: string
Expand Down
Loading
Loading