run method

Future<SyncReport?> run()

Runs a pass for a reason arising now, unless one that began pulling since then has completed by the time this one could start.

Answers with the pass's report, or null when an earlier-started request's pass already brought the replica past this moment. A request arriving mid-pass waits for that pass rather than joining it, because a pull that began before the request may have missed what prompted it.

Implementation

Future<SyncReport?> run() async {
  final requestedAt = _clock();
  SyncReport? report;
  await _lock(() async {
    final syncedAt = await _replica.lastSyncedAt();
    if (syncedAt != null && !syncedAt.isBefore(requestedAt)) return;
    report = await _run();
  });
  return report;
}