2023-06-10 11:06:02 +00:00
|
|
|
import type { DecryptCommandPayload } from '~/decrypt-worker/types';
|
2023-05-17 23:04:37 +00:00
|
|
|
import { DECRYPTION_WORKER_ACTION_NAME, DecryptionResult } from '~/decrypt-worker/constants';
|
2023-06-10 11:06:02 +00:00
|
|
|
|
2023-05-16 21:47:47 +00:00
|
|
|
import { ConcurrentQueue } from './ConcurrentQueue';
|
|
|
|
import { WorkerClientBus } from './WorkerEventBus';
|
|
|
|
|
2023-06-10 11:06:02 +00:00
|
|
|
export class DecryptionQueue extends ConcurrentQueue<DecryptCommandPayload, DecryptionResult> {
|
2023-05-16 21:47:47 +00:00
|
|
|
constructor(private workerClientBus: WorkerClientBus<DECRYPTION_WORKER_ACTION_NAME>, maxQueue?: number) {
|
|
|
|
super(maxQueue);
|
|
|
|
}
|
|
|
|
|
2023-06-10 11:06:02 +00:00
|
|
|
async handler(item: DecryptCommandPayload): Promise<DecryptionResult> {
|
2023-05-21 16:58:54 +00:00
|
|
|
return this.workerClientBus.request(DECRYPTION_WORKER_ACTION_NAME.DECRYPT, item);
|
2023-05-16 21:47:47 +00:00
|
|
|
}
|
|
|
|
}
|