fix: code review cleanup
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { Injectable, Logger, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
import { Injectable, Logger, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
||||||
import Redis from 'ioredis';
|
import Redis from 'ioredis';
|
||||||
import { TaskDto, TaskStatus, EnqueueTaskDto, UpdateTaskStatusDto, TaskMetadata } from './dto/task.dto';
|
import { TaskDto, TaskStatus, EnqueueTaskDto, UpdateTaskStatusDto } from './dto/task.dto';
|
||||||
import { randomUUID } from 'crypto';
|
import { randomUUID } from 'crypto';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,7 +15,7 @@ import { randomUUID } from 'crypto';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class ValkeyService implements OnModuleInit, OnModuleDestroy {
|
export class ValkeyService implements OnModuleInit, OnModuleDestroy {
|
||||||
private readonly logger = new Logger(ValkeyService.name);
|
private readonly logger = new Logger(ValkeyService.name);
|
||||||
private client: Redis;
|
private client!: Redis;
|
||||||
private readonly QUEUE_KEY = 'mosaic:task:queue';
|
private readonly QUEUE_KEY = 'mosaic:task:queue';
|
||||||
private readonly TASK_PREFIX = 'mosaic:task:';
|
private readonly TASK_PREFIX = 'mosaic:task:';
|
||||||
private readonly TASK_TTL = 86400; // 24 hours in seconds
|
private readonly TASK_TTL = 86400; // 24 hours in seconds
|
||||||
@@ -55,7 +55,8 @@ export class ValkeyService implements OnModuleInit, OnModuleDestroy {
|
|||||||
await this.client.ping();
|
await this.client.ping();
|
||||||
this.logger.log('Valkey health check passed');
|
this.logger.log('Valkey health check passed');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error('Valkey health check failed:', error.message);
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||||
|
this.logger.error('Valkey health check failed:', errorMessage);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,7 +143,8 @@ export class ValkeyService implements OnModuleInit, OnModuleDestroy {
|
|||||||
try {
|
try {
|
||||||
return JSON.parse(taskData) as TaskDto;
|
return JSON.parse(taskData) as TaskDto;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(`Failed to parse task data for ${taskId}:`, error.message);
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||||
|
this.logger.error(`Failed to parse task data for ${taskId}:`, errorMessage);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,7 +224,8 @@ export class ValkeyService implements OnModuleInit, OnModuleDestroy {
|
|||||||
const result = await this.client.ping();
|
const result = await this.client.ping();
|
||||||
return result === 'PONG';
|
return result === 'PONG';
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error('Valkey health check failed:', error.message);
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||||
|
this.logger.error('Valkey health check failed:', errorMessage);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user