refactor(server): send job command (#2777)

* refactor: send job command

* chore: open api
This commit is contained in:
Jason Rasmussen
2023-06-16 15:36:07 -04:00
committed by GitHub
parent f04e47803c
commit fde410e2ac
12 changed files with 49 additions and 44 deletions

View File

@@ -6,5 +6,5 @@ export class JobIdDto {
@IsNotEmpty()
@IsEnum(QueueName)
@ApiProperty({ type: String, enum: QueueName, enumName: 'JobName' })
jobId!: QueueName;
id!: QueueName;
}

View File

@@ -23,22 +23,28 @@ export class JobService {
this.configCore = new SystemConfigCore(configRepository);
}
handleCommand(queueName: QueueName, dto: JobCommandDto): Promise<void> {
async handleCommand(queueName: QueueName, dto: JobCommandDto): Promise<JobStatusDto> {
this.logger.debug(`Handling command: queue=${queueName},force=${dto.force}`);
switch (dto.command) {
case JobCommand.START:
return this.start(queueName, dto);
await this.start(queueName, dto);
break;
case JobCommand.PAUSE:
return this.jobRepository.pause(queueName);
await this.jobRepository.pause(queueName);
break;
case JobCommand.RESUME:
return this.jobRepository.resume(queueName);
await this.jobRepository.resume(queueName);
break;
case JobCommand.EMPTY:
return this.jobRepository.empty(queueName);
await this.jobRepository.empty(queueName);
break;
}
return this.getJobStatus(queueName);
}
async getJobStatus(queueName: QueueName): Promise<JobStatusDto> {