Jelajahi Sumber

remove PageBulkExportJobStreamManager

Futa Arai 1 tahun lalu
induk
melakukan
3cdff6b6ae

+ 0 - 35
apps/app/src/features/page-bulk-export/server/service/page-bulk-export/page-bulk-export-job-stream-manager.ts

@@ -1,35 +0,0 @@
-import type { Readable } from 'stream';
-
-import type { ObjectIdLike } from '~/server/interfaces/mongoose-utils';
-
-import { BulkExportJobExpiredError, BulkExportJobRestartedError } from './errors';
-
-/**
- * Used to keep track of streams currently being executed, and enable destroying them
- */
-export class PageBulkExportJobStreamManager {
-
-  private jobStreams: Record<string, Readable> = {};
-
-  addJobStream(jobId: ObjectIdLike, stream: Readable): void {
-    this.jobStreams[jobId.toString()] = stream;
-  }
-
-  removeJobStream(jobId: ObjectIdLike): void {
-    delete this.jobStreams[jobId.toString()];
-  }
-
-  destroyJobStream(jobId: ObjectIdLike, restarted = false): void {
-    const stream = this.jobStreams[jobId.toString()];
-    if (stream != null) {
-      if (restarted) {
-        stream.destroy(new BulkExportJobRestartedError());
-      }
-      else {
-        stream.destroy(new BulkExportJobExpiredError());
-      }
-    }
-    this.removeJobStream(jobId);
-  }
-
-}