import { ProtocolIo, RunOpts } from "./types.js"; import { AsyncLock } from "@tursodatabase/database-common"; /** * Configuration for {@link retryFetch}. */ export interface RetryFetchOpts { /** total number of attempts (including the first try). must be >= 1. default: 3 */ attempts?: number; /** delay before the second attempt, in milliseconds. default: 500 */ delayMs?: number; /** multiplier applied to {@link delayMs} after each failed attempt. default: 2 */ backoff?: number; /** underlying fetch implementation to retry around. default: globalThis.fetch */ fetch?: typeof fetch; } /** * Wraps a fetch implementation in a retry/backoff loop. Plug into * {@link DatabaseOpts.fetch} to give the sync engine resilient HTTP transport. * * Retries on: * - thrown network errors (DNS, connection reset, AbortError, etc.) * - 5xx server responses * - 429 rate-limit responses * * Does NOT retry on: * - 2xx, 3xx, or other 4xx responses (auth/bad-request — won't fix itself) * * Defaults: 3 attempts (initial + 2 retries), 500ms initial delay, 2x backoff * (so delays are 500ms, 1000ms between attempts). * * @example * ```ts * import { connect } from '@tursodatabase/sync'; * import { retryFetch } from '@tursodatabase/sync-common'; * * const db = await connect({ * path: 'local.db', * url: 'libsql://...', * fetch: retryFetch(), // defaults * // fetch: retryFetch({ attempts: 5, delayMs: 1000 }), * }); * ``` */ export declare function retryFetch(opts?: RetryFetchOpts): typeof fetch; export declare function memoryIO(): ProtocolIo; export interface Runner { wait(): Promise; } export declare function runner(opts: RunOpts, io: ProtocolIo, engine: any): Runner; export declare function run(runner: Runner, generator: any): Promise; export declare class SyncEngineGuards { waitLock: AsyncLock; pushLock: AsyncLock; pullLock: AsyncLock; checkpointLock: AsyncLock; constructor(); wait(f: () => Promise): Promise; push(f: () => Promise): Promise; apply(f: () => Promise): Promise; checkpoint(f: () => Promise): Promise; } //# sourceMappingURL=run.d.ts.map