commit 2 refactor
This commit is contained in:
parent
588f666943
commit
32e43c9243
310 changed files with 33318 additions and 31189 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { QueueManager } from './queue-manager';
|
||||
import type { QueueManager } from './queue-manager';
|
||||
import type { BatchJobData, BatchResult, JobData, ProcessOptions } from './types';
|
||||
|
||||
/**
|
||||
|
|
@ -9,7 +9,7 @@ export async function processItems<T>(
|
|||
items: T[],
|
||||
queueName: string,
|
||||
options: ProcessOptions,
|
||||
queueManager: QueueManager
|
||||
queueManager: Pick<QueueManager, keyof QueueManager>
|
||||
): Promise<BatchResult> {
|
||||
const queue = queueManager.getQueue(queueName);
|
||||
const logger = queue.createChildLogger('batch-processor', {
|
||||
|
|
@ -61,7 +61,7 @@ async function processDirect<T>(
|
|||
items: T[],
|
||||
queueName: string,
|
||||
options: ProcessOptions,
|
||||
queueManager: QueueManager
|
||||
queueManager: Pick<QueueManager, keyof QueueManager>
|
||||
): Promise<Omit<BatchResult, 'duration'>> {
|
||||
const queue = queueManager.getQueue(queueName);
|
||||
const logger = queue.createChildLogger('batch-direct', {
|
||||
|
|
@ -109,7 +109,7 @@ async function processBatched<T>(
|
|||
items: T[],
|
||||
queueName: string,
|
||||
options: ProcessOptions,
|
||||
queueManager: QueueManager
|
||||
queueManager: Pick<QueueManager, keyof QueueManager>
|
||||
): Promise<Omit<BatchResult, 'duration'>> {
|
||||
const queue = queueManager.getQueue(queueName);
|
||||
const logger = queue.createChildLogger('batch-batched', {
|
||||
|
|
@ -174,7 +174,7 @@ async function processBatched<T>(
|
|||
export async function processBatchJob(
|
||||
jobData: BatchJobData,
|
||||
queueName: string,
|
||||
queueManager: QueueManager
|
||||
queueManager: Pick<QueueManager, keyof QueueManager>
|
||||
): Promise<unknown> {
|
||||
const queue = queueManager.getQueue(queueName);
|
||||
const logger = queue.createChildLogger('batch-job', {
|
||||
|
|
@ -258,7 +258,7 @@ async function storeItems<T>(
|
|||
items: T[],
|
||||
queueName: string,
|
||||
options: ProcessOptions,
|
||||
queueManager: QueueManager
|
||||
queueManager: Pick<QueueManager, keyof QueueManager>
|
||||
): Promise<string> {
|
||||
const cache = queueManager.getCache(queueName);
|
||||
const payloadKey = `payload:${Date.now()}:${Math.random().toString(36).substr(2, 9)}`;
|
||||
|
|
@ -284,7 +284,7 @@ async function storeItems<T>(
|
|||
async function loadPayload<T>(
|
||||
key: string,
|
||||
queueName: string,
|
||||
queueManager: QueueManager
|
||||
queueManager: Pick<QueueManager, keyof QueueManager>
|
||||
): Promise<{
|
||||
items: T[];
|
||||
options: {
|
||||
|
|
@ -311,7 +311,7 @@ async function loadPayload<T>(
|
|||
async function cleanupPayload(
|
||||
key: string,
|
||||
queueName: string,
|
||||
queueManager: QueueManager
|
||||
queueManager: Pick<QueueManager, keyof QueueManager>
|
||||
): Promise<void> {
|
||||
const cache = queueManager.getCache(queueName);
|
||||
await cache.del(key);
|
||||
|
|
@ -320,7 +320,7 @@ async function cleanupPayload(
|
|||
async function addJobsInChunks(
|
||||
queueName: string,
|
||||
jobs: Array<{ name: string; data: JobData; opts?: Record<string, unknown> }>,
|
||||
queueManager: QueueManager,
|
||||
queueManager: Pick<QueueManager, keyof QueueManager>,
|
||||
chunkSize = 100
|
||||
): Promise<unknown[]> {
|
||||
const queue = queueManager.getQueue(queueName);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue