test: get coverage work

This commit is contained in:
鲁树人
2023-05-16 22:47:47 +01:00
parent e60e669d32
commit 1fafe34fa1
4 changed files with 22 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
import { ConcurrentQueue } from '~/util/ConcurrentQueue';
import { WorkerClientBus } from '~/util/WorkerEventBus';
import { DECRYPTION_WORKER_ACTION_NAME } from './constants';
import { DecryptionQueue } from '~/util/DecryptionQueue';
// TODO: Worker pool?
export const workerClient = new Worker(new URL('./worker', import.meta.url), { type: 'module' });
@@ -8,15 +8,5 @@ export const workerClient = new Worker(new URL('./worker', import.meta.url), { t
// FIXME: report the error so is obvious to the user.
workerClient.onerror = (err) => console.error(err);
class DecryptionQueue extends ConcurrentQueue<{ id: string; blobURI: string }> {
constructor(private workerClientBus: WorkerClientBus<DECRYPTION_WORKER_ACTION_NAME>, maxQueue?: number) {
super(maxQueue);
}
async handler(item: { id: string; blobURI: string }): Promise<void> {
return this.workerClientBus.request(DECRYPTION_WORKER_ACTION_NAME.DECRYPT, item.blobURI);
}
}
export const workerClientBus = new WorkerClientBus<DECRYPTION_WORKER_ACTION_NAME>(workerClient);
export const decryptionQueue = new DecryptionQueue(workerClientBus);