@clickup/ent-framework
Version:
A PostgreSQL graph-database-alike library with microsharding and row-level security
47 lines • 2.2 kB
TypeScript
import { type MaybeCallable } from "../internal/misc";
/**
* A side effect based container which holds the current master or replica
* timeline position. For master, the expectation is that the pos will be
* updated after each query only, so no need to use refreshMs. For replica, it's
* also updated after each query PLUS the class will call triggerRefresh() hook
* not more often than every refreshMs interval.
*/
export declare class TimelineManager {
/** Time interval after which a replica is declared as "caught up" even if
* it's not caught up. This is to not read from master forever when
* something has happened with the replica. */
readonly maxLagMs: MaybeCallable<number>;
/** Up to how often we call triggerRefresh(). */
private refreshMs;
/** This method is called time to time to refresh the data which is later
* returned by currentPos(). Makes sense for replica connections which
* execute queries rarely: for them, the framework triggers the update when
* the fresh data is needed. */
private triggerRefresh;
private pos;
private changeTime;
private triggerRefreshPromise;
constructor(
/** Time interval after which a replica is declared as "caught up" even if
* it's not caught up. This is to not read from master forever when
* something has happened with the replica. */
maxLagMs: MaybeCallable<number>,
/** Up to how often we call triggerRefresh(). */
refreshMs: MaybeCallable<number>,
/** This method is called time to time to refresh the data which is later
* returned by currentPos(). Makes sense for replica connections which
* execute queries rarely: for them, the framework triggers the update when
* the fresh data is needed. */
triggerRefresh: () => Promise<unknown>);
/**
* Returns the current Client's replication timeline position (e.g. WAL
* position).
*/
currentPos(): Promise<bigint>;
/**
* Sets the actual timeline pos. Must be called by the Client after each
* interaction with the database.
*/
setCurrentPos(pos: bigint, force?: boolean): void;
}
//# sourceMappingURL=TimelineManager.d.ts.map