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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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> {

View file

@ -14,7 +14,7 @@ import { MemoryLaneResponseDto } from '@app/domain/asset/response-dto/memory-lan
export class AssetController {
constructor(private service: AssetService) {}
@Get('/map-marker')
@Get('map-marker')
getMapMarkers(@GetAuthUser() authUser: AuthUserDto, @Query() options: MapMarkerDto): Promise<MapMarkerResponseDto[]> {
return this.service.getMapMarkers(authUser, options);
}

View file

@ -28,7 +28,7 @@ import { UUIDParamDto } from './dto/uuid-param.dto';
@Authenticated()
@UseValidation()
export class AuthController {
constructor(private readonly service: AuthService) {}
constructor(private service: AuthService) {}
@PublicRoute()
@Post('login')

View file

@ -16,9 +16,8 @@ export class JobController {
return this.service.getAllJobsStatus();
}
@Put('/:jobId')
async sendJobCommand(@Param() { jobId }: JobIdDto, @Body() dto: JobCommandDto): Promise<JobStatusDto> {
await this.service.handleCommand(jobId, dto);
return this.service.getJobStatus(jobId);
@Put(':id')
sendJobCommand(@Param() { id }: JobIdDto, @Body() dto: JobCommandDto): Promise<JobStatusDto> {
return this.service.handleCommand(id, dto);
}
}