mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-15 13:46:16 -08:00
- Added DatabaseWorkerClient to manage database operations in a worker thread. - Created database-worker-client.ts to handle requests and responses between the main process and the worker. - Introduced database-worker.types.ts for type definitions related to worker messages and operations. - Implemented database.worker.ts to execute various database operations, including CRUD operations for playlists, content, and favorites. - Added database.worker-connection.ts to manage database connections and ensure proper handling of SQLite instances. - Created tests for DatabaseWorkerClient to ensure correct request handling and error management. - Updated xtream.events.ts to allow suppression of error logging for specific requests. - Enhanced EPG parser worker to include a busy timeout for SQLite operations. - Integrated shutdown logic for the DatabaseWorkerClient in the main application lifecycle.
41 lines
942 B
TypeScript
41 lines
942 B
TypeScript
export interface OperationProgressUpdate {
|
|
phase: string;
|
|
current?: number;
|
|
total?: number;
|
|
increment?: number;
|
|
}
|
|
|
|
export interface OperationControl {
|
|
checkpoint?: () => void | Promise<void>;
|
|
onProgress?: (
|
|
progress: OperationProgressUpdate
|
|
) => void | Promise<void>;
|
|
}
|
|
|
|
export async function checkpointOperation(
|
|
control?: OperationControl
|
|
): Promise<void> {
|
|
await control?.checkpoint?.();
|
|
}
|
|
|
|
export async function reportOperationProgress(
|
|
control: OperationControl | undefined,
|
|
progress: OperationProgressUpdate
|
|
): Promise<void> {
|
|
await control?.onProgress?.(progress);
|
|
await checkpointOperation(control);
|
|
}
|
|
|
|
export function chunkValues<T>(
|
|
values: T[],
|
|
chunkSize: number
|
|
): T[][] {
|
|
const chunks: T[][] = [];
|
|
|
|
for (let index = 0; index < values.length; index += chunkSize) {
|
|
chunks.push(values.slice(index, index + chunkSize));
|
|
}
|
|
|
|
return chunks;
|
|
}
|