thing im pretty much done with extracting the queue and making it reususable, maybe just a few more change to be able to making the batch names a bit more specific

This commit is contained in:
Boki 2025-06-14 18:22:28 -04:00
parent ad5e353ec3
commit e8c90532d5
14 changed files with 117 additions and 93 deletions

View file

@ -56,7 +56,7 @@ export async function processItems<T>(
totalItems: items.length,
mode: options.useBatching ? 'batch' : 'direct',
batchSize: options.batchSize,
totalDelayMs: options.totalDelayMs,
totalDelayHours: options.totalDelayHours,
});
try {
@ -86,7 +86,8 @@ async function processDirect<T>(
queue: QueueManager,
options: ProcessOptions
): Promise<Omit<BatchResult, 'duration'>> {
const delayPerItem = options.totalDelayMs / items.length;
const totalDelayMs = options.totalDelayHours * 60 * 60 * 1000; // Convert hours to milliseconds
const delayPerItem = totalDelayMs / items.length;
logger.info('Creating direct jobs', {
totalItems: items.length,
@ -130,7 +131,8 @@ async function processBatched<T>(
): Promise<Omit<BatchResult, 'duration'>> {
const batchSize = options.batchSize || 100;
const batches = createBatches(items, batchSize);
const delayPerBatch = options.totalDelayMs / batches.length;
const totalDelayMs = options.totalDelayHours * 60 * 60 * 1000; // Convert hours to milliseconds
const delayPerBatch = totalDelayMs / batches.length;
logger.info('Creating batch jobs', {
totalItems: items.length,

View file

@ -8,7 +8,7 @@ export interface JobData {
}
export interface ProcessOptions {
totalDelayMs: number;
totalDelayHours: number;
batchSize?: number;
priority?: number;
useBatching?: boolean;