async function waitForExportToComplete()

in src/ExportJournal.ts [284:303]


async function waitForExportToComplete(
    ledgerName: string, 
    exportId: string,
    qldbClient: QLDB
): Promise<JournalS3ExportDescription> {
    log(`Waiting for JournalS3Export for ${exportId} to complete...`);
    let count: number = 0;
    while (count < MAX_RETRY_COUNT) {
        const exportDescription: JournalS3ExportDescription =
            (await describeJournalExport(ledgerName, exportId, qldbClient)).ExportDescription;
        if (exportDescription.Status === 'COMPLETED') {
            log("JournalS3Export completed.");
            return exportDescription;
        }
        log("JournalS3Export is still in progress. Please wait.");
        await sleep(EXPORT_COMPLETION_POLL_PERIOD_MS);
        count += 1;
    }
    throw new Error(`Journal Export did not complete for ${exportId}.`);
}